Solvent Swap from Ethanol to n-Heptane¶
In this tutorial you will take ibuprofen out of the ethanol it was made in and crystallize it from n-heptane. A distillation column swaps the solvent, a cooling crystallizer makes the crystals, a filter and a vacuum dryer give the product, and the mother liquor goes back to the column through a recycle with a purge. At the end you see how much heptane the swap uses and why the column has to remove all the ethanol.
What you will learn
- Why a product is moved from one solvent to another before it is crystallized
- How an azeotrope sets the solvent a swap column uses
- How to give two parts of a flowsheet two property packages, and why the crystallization section needs its own
- How a Crystallizer, a Filter and a vacuum dryer turn a solution into a dry product
- How to close a mother liquor recycle with a purge, and what the purge costs in yield
Prerequisites
- Completed Cooling Crystallization with Measured Solubilities and Distillation Column
- DWSIM 10.3.0 or later (Crystallizer with the solubility from the property package)
Process Overview¶
A solvent swap takes a product out of the solvent it was made in and into the solvent it will be crystallized from. Ibuprofen is very soluble in ethanol, so a cooling crystallization from ethanol would leave much of it in the mother liquor. In cold n-heptane it is only slightly soluble, which makes heptane a good crystallization solvent.
The swap is done in a distillation column. The solution in ethanol and fresh heptane enter together, ethanol leaves overhead and the ibuprofen leaves in heptane from the reboiler. Ethanol and n-heptane form a minimum-boiling azeotrope, so the ethanol can't leave the column alone: it takes heptane with it, and that heptane sets how much make-up the plant needs.
The bottoms are cooled in two steps, first in a cooler and then in a cooling crystallizer at 5 °C. A rotary vacuum filter separates the crystals, a vacuum dryer takes the heptane out of the cake, and the mother liquor returns to the column. A small purge keeps the impurities of a real plant from building up in the loop, and it also takes some ibuprofen with it.
graph LR
F["Ibuprofen in ethanol"] --> M["MIX-101"]
H["Make-up n-heptane"] --> M
M --> HT["H-101<br/>65 °C"] --> T["T-101<br/>swap column"]
T -- distillate --> D["C-103<br/>ethanol and heptane<br/>to recovery"]
T -- bottoms --> C["C-101<br/>60 °C"] --> CR["CRY-101<br/>5 °C"]
CR --> FT["FT-101<br/>filter"]
FT -- wet cake --> DR["DRY-101 + V-101<br/>50 °C, 0.1 bar"] --> P["Ibuprofen product"]
DR -- vapor --> CO["C-102 + P-102"]
FT -- mother liquor --> SP["P-101 + SPL-101"]
SP -- 5 % --> PU["Purge"]
SP -- 95 % --> R["MIX-103 + REC-101"]
CO --> R
R --> M
Key Design Parameters¶
| Parameter | Value |
|---|---|
| Compounds | Ibuprofen, Ethanol, N-heptane |
| Property packages | two NRTL packages: one for the crystallization section, one for the swap column |
| Feed | 500 kg/h of ibuprofen in 500 kg/h of ethanol, 30 °C, 1.5 bar |
| Make-up | 800 kg/h of n-heptane, 25 °C, 1.5 bar |
| Swap column T-101 | 8 stages, feed on Stage4, 1.01325 bar, reflux ratio 1.5, bottoms 19 kmol/h |
| Crystallizer CRY-101 | cooling mode, 5 °C, solubility from the property package |
| Filter FT-101 | sizing mode, 0.4 bar of pressure drop, 15 % of liquor in the cake |
| Dryer DRY-101 | 50 °C, 0.1 bar |
| Purge SPL-101 | 5 % of the mother liquor |
Step-by-Step in the Classic UI¶
1. Set up¶
File > New Chemical Process Model: add Ibuprofen, Ethanol and N-heptane. Ibuprofen isn't in the standard databases; it comes with DWSIM in the additional compounds folder. The values below are in °C, bar, kg/h and kW.
Add two NRTL property packages and rename them NRTL + solids (crystallization) and NRTL (swap column).
Why two property packages
The NRTL pairs of ibuprofen with heptane and with ethanol were fitted to solubilities measured between 9 and 40 °C. They describe the crystallizer well, but the column works from 70 to 105 °C, above the melting point of ibuprofen (76 °C) and far outside the range of the fit. At those temperatures the fitted pairs can predict two liquid phases, and a separator at 90 °C stopped on them in a test. The column package treats ibuprofen as an ideal heavy compound instead. It boils far above the two solvents, so the column only has to keep it in the bottoms, and an ideal solution does that.
2. Configure the crystallization package¶
Open the configuration of NRTL + solids (crystallization) and type the two pairs of ibuprofen in the Interaction Parameters tab, with ibuprofen as compound 1:
| Pair | A12 (cal/mol) | A21 (cal/mol) | B12 (cal/(mol K)) | B21 (cal/(mol K)) | alpha |
|---|---|---|---|---|---|
| Ibuprofen / N-heptane | -1145.2 | 3186.1 | 0 | 0 | 0.2 |
| Ibuprofen / Ethanol | -3549.744 | 6877.817 | 9.67178 | -19.13966 | 0.3 |
The heptane pair is the one tutorial A10 fits to five measured points. The ethanol pair has energies that change with the temperature (A + B T) and was fitted to solubilities in ethanol from 10 to 40 °C. The ethanol / n-heptane pair comes from the database (A12 = 1137.3 and A21 = 1453.6 cal/mol, alpha = 0.479), and it is the pair that gives the azeotrope.
Uncheck Try Automatic Estimation of Missing NRTL/UNIQUAC/Wilson Parameters, and check Handle Solids in the flash settings of the package. With that setting, the flashes of the streams below the crystallizer keep the ibuprofen crystals solid, so the crystals don't melt back into the liquor in the mixer, the filter or the dryer.
3. Configure the column package¶
In NRTL (swap column), set the two pairs of ibuprofen to zero (A12 = A21 = 0, alpha = 0.3) and uncheck the automatic estimation too. The ethanol / n-heptane pair stays as the database gives it.
4. Specify the feeds¶
| Stream | T (°C) | P (bar) | Composition |
|---|---|---|---|
Ibuprofen in ethanol |
30 | 1.5 | 500 kg/h of ibuprofen, 500 kg/h of ethanol |
Make-up n-heptane |
25 | 1.5 | 800 kg/h of n-heptane |
Recycle return |
5 | 1.5 | first estimate: 30 kg/h of ibuprofen, 1570 kg/h of n-heptane |
Recycle return is the outlet of the recycle block of step 9. The first estimate is close to the converged mother liquor, so the loop starts near its solution.
5. Feed mixer, heater and the swap column¶
Connect the three streams to the mixer MIX-101, which gives Column feed, cold. Add the heater H-101 with an outlet temperature of 65 °C and a pressure drop of 0.48675 bar, so that Column feed reaches the column at 1.01325 bar.
Add a Distillation Column T-101 with the streams Distillate and Bottoms and the energy streams Q cond T-101 and Q reb T-101. Set:
| Tab | Parameter | Value |
|---|---|---|
| General | Number of Stages | 8 |
| General | Condenser/Top Pressure | 1.01325 bar |
| General | Maximum Number of Iterations | 200 |
| General | Property Package | NRTL (swap column) |
| Connections | Column Feed Port #1 | Column feed, on Stage4 |
| Specifications > Condenser | Condenser Type / Specification | Total / Reflux Ratio 1.5 |
| Specifications > Reboiler | Specification | Product Molar Flow 5.27778 mol/s (19 kmol/h) |


The bottoms rate is the ibuprofen plus the heptane that goes with it to the crystallizer; everything else that enters the column leaves overhead. Add the cooler C-103 on the distillate, with an outlet temperature of 30 °C, to make Ethanol and heptane to recovery.
Set NRTL (swap column) as the property package of H-101, C-103 and the streams Column feed, Distillate, Bottoms and Ethanol and heptane to recovery. The other blocks and streams use NRTL + solids (crystallization).
Eight stages, and 200 iterations
The default bubble point solver (Wang-Henke) converges this column in about 2 s from the first estimates when it may take up to 200 iterations; with the default limit of 100 it stops before it converges. With 12 or 20 stages it didn't converge, and the slower Naphtali-Sandholm solver had to take over, which is too slow inside a recycle. Eight stages already leave the bottoms free of ethanol.
6. Cooling crystallization¶
Add the cooler C-101 on Bottoms, with an outlet temperature of 60 °C, which gives Solution in heptane. Then add a Crystallizer CRY-101 from Bioprocess Ops, with the products Crystals and Crystallizer liquor, and set it as in tutorial A10:
| Parameter | Value |
|---|---|
| Mode | Cooling |
| Solubility Source | PropertyPackage |
| Solute Compound | Ibuprofen |
| Solvent Compound | N-heptane |
| Operating Temperature | 5 °C |
The mixer MIX-102 joins Crystals and Crystallizer liquor into the Slurry that goes to the filter.
7. Filtration¶
Add a Filter FT-101 with Slurry as the inlet, Mother liquor on outlet 1 and Wet cake on outlet 2. Choose the Sizing calculation mode, a pressure drop of 0.4 bar and a cake humidity of 15 %. In this mode the filter finds the area it needs for the pressure drop you give.

The area comes from the default cake and medium resistances of the block, so it is only illustrative. A real filter is sized with resistances measured on the slurry.
8. Vacuum drying¶
The heater DRY-101 takes the wet cake to 50 °C with a pressure drop of 0.51325 bar, so that Dryer outlet leaves at 0.1 bar. The separator V-101 splits it into Dryer vapor and Ibuprofen product. The cooler C-102 condenses the vapor at 5 °C, and the pump P-102 takes the Dryer condensate to 1.5 bar.
9. Close the mother liquor loop¶
The pump P-101 takes the Mother liquor to 1.5 bar. The splitter SPL-101 sends 95 % of it to Recycled liquor and 5 % to Purge, and the mixer MIX-103 joins the recycled liquor with the pumped condensate into Recycle. Add a Recycle block REC-101 from Recycle to Recycle return, which you already connected to MIX-101 in step 5.
10. Solve and read the results¶
Press Solve. The flowsheet converges in about 2 s.

| Result | Value |
|---|---|
| Distillate of T-101 | 1222.0 kg/h at 71.4 °C, 40.9 wt % ethanol, 722.0 kg/h of heptane |
| Bottoms of T-101 | 2175.5 kg/h at 103.4 °C, 24.3 wt % ibuprofen, ethanol below 1 ppm |
| Condenser / reboiler of T-101 | 466 / 527 kW |
| Ibuprofen crystallized in CRY-101 per pass | 94.1 % |
| Crystals in the slurry | 22.8 wt % |
| Ibuprofen at saturation in the liquor at 5 °C | 0.92 mol % |
| Filter area FT-101 | 2.54 m² |
| Recycle to the column | 1597.5 kg/h |
| Purge | 79.5 kg/h, with 1.49 kg/h of ibuprofen |
| Product | 498.5 kg/h |
| Yield | 99.7 % |
| Heptane used per kg of product | 1.60 kg, of which 1.45 kg leave with the ethanol |
| Duties H-101 / C-101 / C-103 / CRY-101 / DRY-101 | 104 / 63 / 35 / 92 / 24 kW |


The azeotrope sets the heptane use: the 500 kg/h of ethanol take 722 kg/h of heptane overhead with them, and the purge takes about 78 kg/h more, so the make-up of 800 kg/h replaces what leaves the loop. The make-up has a floor: in this flowsheet the swap still converges with 725 kg/h, but at 700 kg/h the column doesn't converge, because the ethanol can't leave overhead without the heptane that the azeotrope carries with it.
Crystallized per pass and yield: CRY-101 crystallizes 94.1 % of the ibuprofen it receives, but the plant yield is 99.7 %, because the mother liquor goes back to the column and only the purge takes ibuprofen out of the loop.
The distillate is a mixture: it leaves with 40.9 wt % of ethanol. A plant recovers the heptane from it, for example by washing the ethanol out with water. The heptane used per kg of product would then fall from 1.60 kg to what the purge takes, about 0.16 kg.
11. Why the column has to remove all the ethanol¶
The script also asks the crystallization package for the solubility of ibuprofen at 5 °C in heptane that still holds a little ethanol:
| Ethanol in the solvent (wt %) | 0 | 0.5 | 1 | 2 | 3 | 5 |
|---|---|---|---|---|---|---|
| Ibuprofen at saturation (mole fraction) | 0.0092 | 0.0129 | 0.0176 | 0.0312 | 0.0503 | 0.0939 |
With 1 wt % of ethanol left in the heptane, twice as much ibuprofen stays dissolved at 5 °C, and with 3 wt % more than five times as much. The model has measured data for each solvent alone, so its values for the mixture are an interpolation, but the trend is the reason a swap column has to send the ethanol overhead completely.
12. How much heptane to send to the crystallizer¶
The bottoms rate of T-101 sets how much heptane goes with the ibuprofen to the crystallizer. Lower it step by step from 19 kmol/h and solve after each change:
| Bottoms rate (kmol/h) | Heptane to CRY-101 (kg/h) | Crystals in the slurry (wt %) | Yield (%) | Reboiler (kW) | Recycle (kg/h) |
|---|---|---|---|---|---|
| 19.0 | 1647 | 22.8 | 99.70 | 527 | 1597 |
| 16.0 | 1349 | 26.6 | 99.76 | 524 | 1309 |
| 14.0 | 1151 | 29.8 | 99.80 | 523 | 1117 |
| 12.0 | 952 | 33.9 | 99.84 | 521 | 924 |
Less heptane gives a denser slurry and a slightly higher yield, because less liquor reaches the purge. The reboiler hardly changes, since it boils the ethanol and the heptane that leaves with it, and those don't change. A slurry with more than 30 wt % of crystals is harder to pump and to filter, which is what limits the bottoms rate in practice.
Change the bottoms rate in small steps
Each solve of the column starts from its previous profile. In this flowsheet the bubble point solver followed the bottoms rate down from 19 to 12 kmol/h, but a jump back up from 12 to 19 kmol/h didn't converge. If that happens, raise the rate in smaller steps, or rebuild the column estimates from the design point.
Results and Validation¶
Expected results
The swap column sends all the ethanol overhead in 1222.0 kg/h of distillate with 40.9 wt % of ethanol, and leaves 2175.5 kg/h of ibuprofen in heptane in the bottoms at 103.4 °C. The crystallizer at 5 °C crystallizes 94.1 % of the ibuprofen per pass, and the plant makes 498.5 kg/h of ibuprofen, a yield of 99.7 %, with 1.60 kg of heptane per kg of product.
The pair of ibuprofen with n-heptane was fitted to the solubilities of Hahnenkamp, Graubner and Gmehling (2010), and the pair with ethanol to those of Rashid et al. (2011). The flowsheet is the one of the Solvent swap of ibuprofen from ethanol to n-heptane case of the Case Library (cases/separation-processes/ibuprofen-solvent-swap-ethanol-to-heptane), and the script reproduces its results. The numbers of the tables come from the Python script below.
Automating This Tutorial¶
Files in this repository
- Python script:
examples/pharma/03_solvent_swap.py - Pre-built flowsheet:
examples/saved/solvent_swap.dwxmz(the design point, with the bottoms rate at 19 kmol/h)
The script runs in every edition. It builds the two property packages and the flowsheet with the FluentAPI, solves the loop and prints the results of step 10. It then prints the solubility table of step 11, saves the flowsheet when DWSIM_SAVE_TO is set, and runs the bottoms rate study of step 12.
import os
import sys
import time
import pythonnet
pythonnet.load("netfx") # DWSIM is a .NET Framework application
import clr # noqa: E402
DWSIM_BIN = os.environ.get("DWSIM_BIN")
if not DWSIM_BIN:
raise SystemExit("Set DWSIM_BIN to the DWSIM installation folder before running.")
for sub in ("", "unitops", "ppacks", "extenders"):
sys.path.append(os.path.join(DWSIM_BIN, sub))
for a in ("DWSIM.Automation", "DWSIM.Automation.FluentAPI", "DWSIM.Thermodynamics", "DWSIM.UnitOperations",
"DWSIM.Interfaces"):
clr.AddReference(a)
from System import Array, Double, String # noqa: E402
from System.Collections.Generic import Dictionary # noqa: E402
from DWSIM.Automation.FluentAPI import Flowsheet, PropertyPackages, Q # noqa: E402
from DWSIM.Interfaces.Enums import FlashSetting # noqa: E402
from DWSIM.Interfaces.Enums.GraphicObjects import ObjectType # noqa: E402
from DWSIM.Thermodynamics.PropertyPackages.Auxiliary import NRTL_IPData, SolidSolubility # noqa: E402
from DWSIM.UnitOperations.UnitOperations import CrystallizerMode, CrystallizerSolubilitySource, Filter # noqa: E402
IBU, ETOH, C7 = "Ibuprofen", "Ethanol", "N-heptane"
BOTTOMS_RATE = 19.0 # kmol/h of ibuprofen and heptane sent from the column to the crystallizer
# --- 1. Compounds and the two property packages ----------------------------------------------------------------------
fs = Flowsheet.Create("Solvent swap of ibuprofen from ethanol to n-heptane").WithCompounds(Array[String]([IBU, ETOH, C7]))
fs = fs.WithPropertyPackage(PropertyPackages.NRTL).WithPropertyPackage(PropertyPackages.NRTL)
cryst_pp, column_pp = [getattr(p, "__implementation__", p) for p in fs.Inner.PropertyPackages.Values]
cryst_pp.Tag = "NRTL + solids (crystallization)"
column_pp.Tag = "NRTL (swap column)"
def set_pair(pp, a12, a21, alpha, b12=0.0, b21=0.0, other=C7):
"""Writes the NRTL pair ibuprofen (1) / other (2), in cal/mol and cal/(mol K), into a package."""
pair = NRTL_IPData()
pair.ID1, pair.ID2 = IBU, other
pair.A12, pair.A21, pair.B12, pair.B21, pair.alpha12 = a12, a21, b12, b21, alpha
pairs = pp.m_uni.InteractionParameters
if pairs.ContainsKey(other):
pairs[other].Remove(IBU)
if not pairs.ContainsKey(IBU):
pairs[IBU] = Dictionary[String, NRTL_IPData]()
pairs[IBU][other] = pair
# crystallization section: pairs fitted to measured solubilities (heptane 9 to 29 C, ethanol 10 to 40 C)
set_pair(cryst_pp, -1145.2, 3186.1, 0.2, other=C7)
set_pair(cryst_pp, -3549.744, 6877.817, 0.3, b12=9.67178, b21=-19.13966, other=ETOH)
cryst_pp.FlashSettings[FlashSetting.HandleSolidsInDefaultEqCalcMode] = "True"
# swap column: ibuprofen is an ideal heavy compound; the ethanol / n-heptane pair comes from the database
set_pair(column_pp, 0.0, 0.0, 0.3, other=C7)
set_pair(column_pp, 0.0, 0.0, 0.3, other=ETOH)
for pp in (cryst_pp, column_pp):
pp.AutoEstimateMissingNRTLUNIQUACParameters = False
def stream(tag, pp=cryst_pp):
ms = fs.AddMaterialStream(tag)
ms.Object.PropertyPackage = pp
return ms
def on_column_package(builder):
builder.Object.PropertyPackage = column_pp
return builder
# --- 2. Feeds -----------------------------------------------------------------------------------------------------------
solution = stream("Ibuprofen in ethanol").At(Q.Celsius(30.0), Q.Bar(1.5))
solution.SetCompoundMassFlow(IBU, 500.0 / 3600.0).SetCompoundMassFlow(ETOH, 500.0 / 3600.0)
makeup = stream("Make-up n-heptane").At(Q.Celsius(25.0), Q.Bar(1.5)).SetCompoundMassFlow(C7, 800.0 / 3600.0)
recycle_back = stream("Recycle return").At(Q.Celsius(5.0), Q.Bar(1.5)) # tear stream, with a first estimate
recycle_back.SetCompoundMassFlow(IBU, 30.0 / 3600.0).SetCompoundMassFlow(C7, 1570.0 / 3600.0)
# --- 3. Feed mixer, heater and the swap column ------------------------------------------------------------------------
feed_cold = stream("Column feed, cold")
fs.AddMixer("MIX-101").ConnectFeed(solution, 0).ConnectFeed(makeup, 1).ConnectFeed(recycle_back, 2).ConnectProduct(feed_cold, 0)
feed = stream("Column feed", column_pp)
on_column_package(fs.AddHeater("H-101").WithOutletTemperature(Q.Celsius(65.0))
.WithPressureDrop(Q.Pascal(150000.0 - 101325.0)).ConnectFeed(feed_cold, 0).ConnectProduct(feed, 0))
distillate, bottoms = stream("Distillate", column_pp), stream("Bottoms", column_pp)
column = on_column_package(
fs.AddDistillationColumn("T-101").WithNumberOfStages(8).WithMaxIterations(200).WithTopPressure(Q.Pascal(101325.0))
.WithFeed(feed, "Stage4").WithDistillate(distillate).WithBottoms(bottoms)
.WithCondenserDuty(fs.AddEnergyStream("Q cond T-101")).WithReboilerDuty(fs.AddEnergyStream("Q reb T-101"))
.WithCondenserSpec("Reflux Ratio", 1.5)
.WithReboilerSpec("Product Molar Flow Rate", BOTTOMS_RATE * 1000.0 / 3600.0, "mol/s"))
to_recovery = stream("Ethanol and heptane to recovery", column_pp)
on_column_package(fs.AddCooler("C-103").WithOutletTemperature(Q.Celsius(30.0)).WithPressureDrop(Q.Pascal(0.0))
.ConnectFeed(distillate, 0).ConnectProduct(to_recovery, 0))
# --- 4. Cooling crystallization, filter and vacuum dryer ---------------------------------------------------------------
warm = stream("Solution in heptane")
fs.AddCooler("C-101").WithOutletTemperature(Q.Celsius(60.0)).WithPressureDrop(Q.Pascal(0.0)) \
.ConnectFeed(bottoms, 0).ConnectProduct(warm, 0)
crystals, liquor = stream("Crystals"), stream("Crystallizer liquor")
cry = fs.AddCrystallizer("CRY-101")
cry.WithMode(CrystallizerMode.Cooling).WithSoluteCompound(IBU).WithSolventCompound(C7)
cry.WithSolubilitySource(CrystallizerSolubilitySource.PropertyPackage)
cry.WithOperatingTemperature(Q.Celsius(5.0))
cry.ConnectFeed(warm, 0).ConnectProduct(crystals, 0).ConnectProduct(liquor, 1)
cry.Object.PropertyPackage = cryst_pp
slurry = stream("Slurry")
fs.AddMixer("MIX-102").ConnectFeed(crystals, 0).ConnectFeed(liquor, 1).ConnectProduct(slurry, 0)
mother_liquor, cake = stream("Mother liquor"), stream("Wet cake")
fs.AddFilter("FT-101").WithCalculationMode(Filter.CalculationMode.Design).WithPressureDrop(Q.Bar(0.4)) \
.WithCakeMoisturePercent(15.0).ConnectFeed(slurry, 0).ConnectProduct(mother_liquor, 0).ConnectProduct(cake, 1)
dryer_out = stream("Dryer outlet")
fs.AddHeater("DRY-101").WithOutletTemperature(Q.Celsius(50.0)).WithPressureDrop(Q.Pascal(61325.0 - 10000.0)) \
.ConnectFeed(cake, 0).ConnectProduct(dryer_out, 0)
vapor, product = stream("Dryer vapor"), stream("Ibuprofen product")
fs.AddSeparator("V-101").ConnectFeed(dryer_out, 0).ConnectProduct(vapor, 0).ConnectProduct(product, 1)
condensate = stream("Dryer condensate")
fs.AddCooler("C-102").WithOutletTemperature(Q.Celsius(5.0)).WithPressureDrop(Q.Pascal(0.0)) \
.ConnectFeed(vapor, 0).ConnectProduct(condensate, 0)
condensate_p = stream("Condensate, pumped")
fs.AddPump("P-102").WithOutletPressure(Q.Bar(1.5)).ConnectFeed(condensate, 0).ConnectProduct(condensate_p, 0)
# --- 5. Mother liquor: pump, purge and recycle to the column ----------------------------------------------------------
liquor_p = stream("Liquor, pumped")
fs.AddPump("P-101").WithOutletPressure(Q.Bar(1.5)).ConnectFeed(mother_liquor, 0).ConnectProduct(liquor_p, 0)
kept, purge = stream("Recycled liquor"), stream("Purge")
fs.AddSplitter("SPL-101").WithSplitRatios(0.95, 0.05).ConnectFeed(liquor_p, 0).ConnectProduct(kept, 0).ConnectProduct(purge, 1)
recycle = stream("Recycle")
fs.AddMixer("MIX-103").ConnectFeed(kept, 0).ConnectFeed(condensate_p, 1).ConnectProduct(recycle, 0)
# the Recycle block has no typed builder: AddUnitOperation takes the ObjectType enum
fs.AddUnitOperation(ObjectType.OT_Recycle, "REC-101").ConnectFeed(recycle, 0).ConnectProduct(recycle_back, 0)
t0 = time.time()
fs.Solve()
print(f"Solved in {time.time() - t0:.1f} s")
# --- 6. Results -------------------------------------------------------------------------------------------------------
def kgh(ms, compound=None):
total = ms.MassFlowKgPerSecond * 3600.0
return total if compound is None else total * ms.OverallMassFraction(compound)
def unit(tag):
o = fs.Inner.GetFlowsheetSimulationObject(tag)
return getattr(o, "__implementation__", o)
def duty(tag):
return abs(unit(tag).DeltaQ)
col, c = column.Object, cry.Object
prod_ibu = kgh(product, IBU)
c7_used = kgh(makeup) / prod_ibu
c7_lost = kgh(distillate, C7) / prod_ibu
print("\nSwap column T-101 (8 stages, feed on Stage4, reflux ratio 1.5)")
print(f" Distillate {kgh(distillate):7.1f} kg/h at {distillate.TemperatureK - 273.15:.1f} C, "
f"{distillate.OverallMassFraction(ETOH) * 100.0:.1f} wt % ethanol, {kgh(distillate, C7):.1f} kg/h of heptane")
print(f" Bottoms {kgh(bottoms):7.1f} kg/h at {bottoms.TemperatureK - 273.15:.1f} C, "
f"ethanol {bottoms.OverallMassFraction(ETOH):.1e} by mass, ibuprofen {bottoms.OverallMassFraction(IBU) * 100.0:.1f} wt %")
print(f" Condenser / reboiler {abs(col.CondenserDuty):.0f} / {abs(col.ReboilerDuty):.0f} kW")
print("\nCrystallizer CRY-101 at 5 C")
print(f" Saturation mole fraction {c.Result_SaturationMoleFraction:.5f}")
print(f" Crystallized per pass {c.Result_Yield * 100.0:.1f} %")
print(f" Crystals in the slurry {c.Result_SolidsInSlurry * 100.0:.1f} wt %")
print(f" Cooling duty {abs(c.Result_Duty_kW):.0f} kW")
print("\nFilter, dryer and recycle")
print(f" Filter area FT-101 {unit('FT-101').TotalFilterArea:.2f} m2")
print(f" Wet cake {kgh(cake):.1f} kg/h")
print(f" Dryer duty {duty('DRY-101'):.0f} kW")
print(f" Recycle to the column {kgh(recycle_back):.1f} kg/h")
print(f" Purge {kgh(purge):.1f} kg/h, with {kgh(purge, IBU):.2f} kg/h of ibuprofen")
print("\nPlant")
print(f" Product {kgh(product):.1f} kg/h, {product.OverallMassFraction(IBU) * 100.0:.2f} wt % ibuprofen")
print(f" Yield {prod_ibu / 500.0 * 100.0:.1f} %")
print(f" Heptane used per kg {c7_used:.2f} kg, of which {c7_lost:.2f} kg leave with the ethanol")
print(f" Duties H-101 / C-101 / C-103 {duty('H-101'):.0f} / {duty('C-101'):.0f} / {duty('C-103'):.0f} kW")
feeds = kgh(solution) + kgh(makeup)
outs = kgh(product) + kgh(purge) + kgh(to_recovery)
print(f" Mass balance in {feeds:.1f} kg/h, out {outs:.1f} kg/h")
# --- 7. Why the ethanol has to leave: solubility at 5 C with ethanol left in the heptane ------------------------------
names = list(cryst_pp.RET_VNAMES())
print("\nEthanol in the solvent against the solubility of ibuprofen at 5 C")
print(f"{'ethanol wt %':>13}{'x ibuprofen':>13}")
for w in (0.0, 0.5, 1.0, 2.0, 3.0, 5.0):
n_e, n_h = w / 46.069, (100.0 - w) / 100.204
x = [0.0] * len(names)
x[names.index(ETOH)], x[names.index(C7)] = n_e / (n_e + n_h), n_h / (n_e + n_h)
cryst_pp.CurrentMaterialStream = liquor.Object
sat = SolidSolubility.Saturation(cryst_pp, names.index(IBU), Array[Double](x), 278.15, 101325.0).MoleFraction
print(f"{w:13.1f}{sat:13.4f}")
out = os.environ.get("DWSIM_SAVE_TO")
if out:
fs.OrthogonalLayout()
fs.Save(out)
fs.SaveScreenshot(os.path.splitext(out)[0] + ".png")
print("saved", out)
# --- 8. How much heptane to send to the crystallizer: the bottoms rate of T-101 --------------------------------------
# The study runs after the save and steps the bottoms rate down from the design point: each solve starts from the
# column profile of the previous one, and the bubble point solver follows small steps in this direction.
print("\nBottoms rate of T-101 against the crystallization")
print(f"{'kmol/h':>8}{'C7 to CRY kg/h':>16}{'solids wt %':>13}{'yield %':>9}{'reboiler kW':>13}{'recycle kg/h':>14}")
for rate in (19.0, 16.0, 14.0, 12.0):
col.Specs["R"].SpecValue = rate * 1000.0 / 3600.0
fs.Solve()
print(f"{rate:8.1f}{kgh(bottoms, C7):16.0f}{c.Result_SolidsInSlurry * 100.0:13.1f}"
f"{kgh(product, IBU) / 500.0 * 100.0:9.2f}{abs(col.ReboilerDuty):13.0f}{kgh(recycle_back):14.0f}")
Exercises
- Raise the purge to 10 %. How much does the yield fall, and how much heptane does the plant then need per kg of product?
- Lower the make-up to 725 kg/h. How much heptane does the plant use per kg of product now, and what happens at 700 kg/h?
- Cool the crystallizer to 0 °C. How much more ibuprofen crystallizes per pass, and how much does the plant yield change, with the recycle in place?
- Move the feed to Stage3 and to Stage5. Which feed stage gives the lowest reboiler duty?
Further Reading¶
- I. Hahnenkamp, G. Graubner and J. Gmehling. (2010). Measurement and prediction of solubilities of active pharmaceutical ingredients. International Journal of Pharmaceutics, 388, 73-81
- A. Rashid, E. T. White, T. Howes, J. D. Litster and I. Marziano. (2011). Crystallization kinetics of ibuprofen from ethanol and aqueous ethanol. 10th International Conference on Chemical and Process Engineering (ICheaP-10)
- A. S. Myerson, D. Erdemir and A. Y. Lee. (2019). Handbook of Industrial Crystallization, 3rd ed. Cambridge University Press
- DWSIM User Guide: the Crystallizer and the Filter
Next Steps¶
You now know how to move a product into the solvent it crystallizes from, why the azeotrope sets the solvent the swap uses, and how a mother liquor recycle with a purge raises the yield of a crystallization. Open the Solvent swap of ibuprofen from ethanol to n-heptane case of the Case Library to see the same flowsheet with its notes and charts, or continue with the Features Track.