Precipitation Reactor¶
DWSIM Plus
Available with a DWSIM Plus (Patreon) subscription.
![]()
Precipitation Reactor — mixes a feed stream and a precipitant stream, identifies sparingly soluble salts that exceed their Ksp, precipitates them to saturation, and outputs a clarified liquid stream and a solid sludge stream. Ports ───── Inlet 0 : Feed (wastewater / process liquor) Inlet 1 : Precipitant (lime, NaOH, Na₂CO₃, FeCl₃, …) — optional Inlet 2 : Duty (energy stream, optional; positive = heat added) Outlet 0 : Clarified liquid Outlet 1 : Solid sludge Algorithm ───────── 1. Mix inlet streams. 2. Estimate ionic strength; compute activity coefficients (Davies or ideal). 3. For each potential precipitate (built-in Ksp database): compute Q = Π(γ_i × c_i)^ν_i if Q > Ksp(T) → precipitate until Q = Ksp (bisection on amount). 4. Repeat until no new supersaturation. 5. Set outlet streams.
DWSIM.UnitOperations.ElectrolyteOps.PrecipitationReactorUnitOperation
Assembly DWSIM.UnitOperations.ElectrolyteOps.dll · Object ← BaseClass ← UnitOpBaseClass ← PrecipitationReactorUnitOperation
At a glance¶

| Port | Index | Connected in the example |
|---|---|---|
| Inlet, material | 0 |
Brine |
| Inlet, material | 1 |
Na2SO4-solution |
| Inlet, energy | 2 |
|
| Outlet, material | 0 |
Clarified |
| Outlet, material | 1 |
Sludge |
Example¶
This code runs on every build of this site, and the output below is what it printed.
# The precipitate leaves as the neutral salt, so it must be in the compound list
fs = (Flowsheet.Create("PrecipitationExample")
.WithCompounds("Water", "Calcium (ion)", "Chloride (ion)", "Sodium (ion)", "Sulfate (ion)",
"Calcium Sulfate (Anhydrite)")
.WithPropertyPackage(PropertyPackages.Plus.ElectrolyteNRTL))
# Brine: 0.2 mol/L CaCl2 in 10 kg/s of water. Precipitant: 2 mol/s of Na2SO4 in 5 kg/s of water
brine = (fs.AddMaterialStream("Brine").At(Q.Celsius(25.0), Q.Bar(2.0))
.SetCompoundMolarFlow("Water", 10.0 / 0.018015)
.SetCompoundMolarFlow("Calcium (ion)", 2.0)
.SetCompoundMolarFlow("Chloride (ion)", 4.0))
reagent = (fs.AddMaterialStream("Na2SO4-solution").At(Q.Celsius(25.0), Q.Bar(2.0))
.SetCompoundMolarFlow("Water", 5.0 / 0.018015)
.SetCompoundMolarFlow("Sodium (ion)", 4.0)
.SetCompoundMolarFlow("Sulfate (ion)", 2.0))
clarified = fs.AddMaterialStream("Clarified")
sludge = fs.AddMaterialStream("Sludge")
pr = (fs.AddPrecipitationReactor("PR-1")
.WithActivityModel(ActivityCoefficientModel.Davies)
.WithOutletTemperature(Q.Celsius(25.0))
.ConnectFeed(brine, 0).ConnectFeed(reagent, 1)
.ConnectProduct(clarified, 0).ConnectProduct(sludge, 1))
fs.AutoLayout()
fs.Solve()
r = pr.Object.Results
gypsum = [p for p in r.PrecipitateResults if p.Formula == "CaSO4"][0]
ca_in = brine.Object.Phases[0].Compounds["Calcium (ion)"].MolarFlow
ca_out = clarified.Object.Phases[0].Compounds["Calcium (ion)"].MolarFlow
print(f"Supersaturation (Q/Ksp) = {gypsum.SupersaturationRatio:.0f}")
print(f"CaSO4 precipitated = {r.OutletSolidMassFlow * 3600.0:.0f} kg/h")
print(f"Calcium removed = {(1.0 - ca_out / ca_in) * 100.0:.1f} %")
print(f"Ionic strength = {r.IonicStrength:.3f} mol/L")
Output
Supersaturation (Q/Ksp) = 27
CaSO4 precipitated = 818 kg/h
Calcium removed = 83.5 %
Ionic strength = 0.343 mol/L
DWSIM 10.2.11.0, generated 2026-10-08.
Properties¶
IDs accepted by GetPropertyValue, SetPropertyValue, the sensitivity analysis, the optimizer, the Adjust block and dynamic events. Units are SI; pass another unit system to GetPropertyValue to get them converted.
| ID | Name | Unit (SI) | Input |
|---|---|---|---|
Use Inlet Temperature |
yes | ||
Outlet Temperature |
K | yes | |
Use Inlet Pressure |
yes | ||
Fixed Pressure |
Pa | yes | |
Activity Coefficient Model |
yes | ||
Outlet Liquid Temperature |
K | result | |
Outlet Pressure |
Pa | result | |
Outlet Liquid Molar Flow |
mol/s | result | |
Solid Mass Flow |
kg/s | result | |
Estimated pH |
result | ||
Ionic Strength |
mol/m3 | result | |
Heat Duty |
kW | result |
Learn more¶
-
FluentAPI
API members¶
Public members declared by this class. Inherited members are documented on the base classes.
Constructors¶
Properties¶
ComponentDescription: Gets or sets the CAPE-OPEN component description for this unit operation.
Gets or sets the CAPE-OPEN component description for this unit operation.
Config: Gets or sets the input configuration: outlet temperature and pressure specifications, activity coefficient model...
Gets or sets the input configuration: outlet temperature and pressure specifications, activity coefficient model, the solid compounds considered for precipitation and the iteration limit and tolerance.
IsPremium: Gets a value indicating that this unit operation is listed in the Premium group of the object palette (always true).
Gets a value indicating that this unit operation is listed in the Premium group of the object palette (always true).
MobileCompatible: Gets a value indicating whether this unit operation is compatible with mobile interfaces (always false).
Gets a value indicating whether this unit operation is compatible with mobile interfaces (always false).
ObjectClass: Gets the simulation object class category (reactors).
Gets the simulation object class category (reactors).
Prefix: Gets the default name prefix for this unit operation ('PR-').
Gets the default name prefix for this unit operation ("PR-").
Methods¶
Calculate(object): Calculates the object.
Calculates the object.
| Parameter | Type | Description |
|---|---|---|
args |
Object |
CloneXML(): Creates a deep copy of this object by round-tripping through XML serialization.
Creates a deep copy of this object by round-tripping through XML serialization.
CloseEditForm(): Closes the editor of this object, if it is open.
Closes the editor of this object, if it is open.
CreateConnectors(): Creates the graphic connector definitions on the flowsheet: feed and precipitant inlets on the left, a Duty (energy)...
Creates the graphic connector definitions on the flowsheet: feed and precipitant inlets on the left, a Duty (energy) inlet at the bottom placed third in the inlet list, and clarified liquid and solid sludge outlets on the right.
DeCalculate(): Decalculates the object.
Decalculates the object.
DisplayEditForm(): Opens the editor of this object.
Opens the editor of this object. A host that has no editor for it does nothing.
Draw(object): Draws the unit operation on the given SkiaSharp canvas: the embedded photo in photorealistic mode (draw mode 2)...
Draws the unit operation on the given SkiaSharp canvas: the embedded photo in photorealistic mode (draw mode 2), otherwise the vector icon.
| Parameter | Type | Description |
|---|---|---|
g |
Object |
The SkiaSharp canvas. |
GetDisplayDescription(): Returns the description string for this unit operation type.
Returns the description string for this unit operation type.
GetDisplayName(): Returns the display name for this unit operation type.
Returns the display name for this unit operation type.
GetIconBitmapBytes(): Returns the raw bytes of the icon image for this unit operation.
Returns the raw bytes of the icon image for this unit operation.
GetPreferredGraphicObjectHeight(): Returns the preferred height of the flowsheet graphic object, in pixels.
Returns the preferred height of the flowsheet graphic object, in pixels.
GetPreferredGraphicObjectWidth(): Returns the preferred width of the flowsheet graphic object, in pixels.
Returns the preferred width of the flowsheet graphic object, in pixels.
GetProperties(PropertyType): Get a list of all properties of the object.
Get a list of all properties of the object.
| Parameter | Type | Description |
|---|---|---|
proptype |
PropertyType |
Type of the property. |
GetPropertyUnit(string, IUnitsOfMeasure): Gets the units of a property.
Gets the units of a property.
| Parameter | Type | Description |
|---|---|---|
prop |
String |
Property identifier. |
su |
IUnitsOfMeasure |
Units system to use. Null to use the default (SI) system. |
GetPropertyValue(string, IUnitsOfMeasure): Returns the value of a named property, converting from SI to the current unit system.
Returns the value of a named property, converting from SI to the current unit system. Falls back to extra properties if the property is not found in the base implementation.
| Parameter | Type | Description |
|---|---|---|
prop |
String |
The property identifier string. |
su |
IUnitsOfMeasure |
Optional units-of-measure system used for conversion; uses the shared SI system when Nothing. |
LoadData(List<XElement>): Restores the unit operation.
Restores the unit operation. The Config element, when present, is loaded into the existing Config; files saved without it keep the default configuration.
| Parameter | Type | Description |
|---|---|---|
data |
List<XElement> |
The XML elements written by SaveData. |
PopulateEditorPanel(object): Populates the cross-platform (Avalonia) editor panel with controls.
Populates the cross-platform (Avalonia) editor panel with controls.
| Parameter | Type | Description |
|---|---|---|
ctner |
Object |
The editor panel (layout container) to populate. |
ReturnInstance(string): Creates and returns a new instance for deserialization.
Creates and returns a new instance for deserialization.
| Parameter | Type | Description |
|---|---|---|
typename |
String |
The type name to instantiate. |
SaveData(): Serializes the unit operation, with its Config written as a Config element.
Serializes the unit operation, with its Config written as a Config element.
SetPropertyValue(string, object, IUnitsOfMeasure): Sets the value of a property.
Sets the value of a property.
| Parameter | Type | Description |
|---|---|---|
prop |
String |
Property identifier. |
propval |
Object |
Property value to set at the specified units. |
su |
IUnitsOfMeasure |
Units system to use. Null to use the default (SI) system. |