Skip to content

Conversation

@daklauss
Copy link
Member

@daklauss daklauss commented Mar 12, 2025

This pull request adds c_cake and n_cake for the DeadEndFiltration model. It also reworks the entire state structure of the unit operation as the following graphics and equations show.

DEF-Model

So now a short summary about the residual equations:
Inlet (note that $\tilde{c}_{in}$ is the connection value between uo.):

$$0=c^{in}_i-\tilde{c}^{in}_i$$ $$0 = \dot{n}^{in}_i -Q^{in}\cdot c^{in}_i$$

Retentate (rej is based on the rejection model):

$$0=\dot{n}^R_i - rej_i \cdot \dot{n}^{in}_i$$

mw are molecular weights, $\rho$ is the density

$$0=\dot{V}_R - \sum_i \dot{n}^R_i * mw_i / \rho_i$$

if \dot{V}_R > 1e-16:

$$0=c^R_i -\dot{n}_i^R / \dot{V}^R$$

else:

$$0=c^R_i$$

Permeate:

$$0=\dot{n}^P_i - rej_i \cdot \dot{n}^{in}_i$$ $$0=\dot{V}_P - \sum_i \dot{n}^P_i \cdot mw_i / \rho_i$$

if \dot{V}_P > 1e-16:

$$0=c^P_i -\dot{n}_i^P / \dot{V}^P$$

else:

$$0=c^P_i$$

Cake Equations:

$$0 = V^C - \sum_i n^C \cdot mw_i/ \rho_i$$ $$0=\dot{n}^C_i - \dot{n}^R_i$$

if V^C> 1e-16:

$$0=\dot{c}^C_i -(\dot{n}_i^C - c^C \cdot \dot{V}^C_i ) / V^C$$

else:

$$0=\dot{c}^C_i$$

Permeate tank equations:

$$0 = \dot{c}^PT_i - (\dot{n}^P_i - Q^{out}\cdot c^{PT}_i - \dot{V}^{PT} \cdot c^{PT}_i) / V^{PT}$$ $$0 = \dot{V}^PT - \dot{V}^P + Q^{out}$$ $$0 = n^{PT}_i - c^{PT}_i \cdot vol^{PT}$$

Pressue equation:
CV is the volume of a specific component

$$CV_i = n^C_i mw_i / \rho_i$$

$R^C$ is the cake resistance, $\alpha$ is the specific cake resistance:

$$R^C= \sum_i \alpha_i \cdot \rho CV_i$$

so the pressure equations is:
if not np.sum(\dot{n}^P) < 1e-16:

$$0 = \Delta P - \mu \cdot \dot{V}^P \cdot (R^M + R^C) / A$$

else:

$$0 = \Delta P$$

@daklauss daklauss force-pushed the Add-tracking-of-c/n-in-cake branch 3 times, most recently from f16ef09 to b0846a9 Compare March 17, 2025 21:54
@daklauss
Copy link
Member Author

daklauss commented Mar 17, 2025

Tests have been updated and additionally n_cake is part of the Unit Operation. For now c_cake is neither tracked nor somehow calculated. The user has to manually calculate c_cake by using n_cake and volume. This can't be used withing the residual because of numerical issues. (Using c= n/V leads to IDA not converging while it is actually not necessary). In a further issue it is maybe necessary to implement an additional functionality to track states/values that aren't used for the residual Calculation.

Copy link
Contributor

@schmoelder schmoelder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move the formatting commit to its own PR.

@schmoelder
Copy link
Contributor

Thanks for taking care of this @daklauss

For now c_cake is neither tracked nor somehow calculated.

Is there a technical reason for this? I believe, the equations should be the same as for c_permeate_tank.

@daklauss daklauss force-pushed the Add-tracking-of-c/n-in-cake branch from b0846a9 to 4009cc5 Compare March 18, 2025 08:45
@daklauss
Copy link
Member Author

They are the same but even the permeate tank is crashing with Volume = 0? But in comparsion it is not reasonable to have an initial cake? I've tried today to vary them in some regards but it leads to IDA not beeing able to converge. I don't know.

In hindsight im a little bit confused why n_in_cake and n_cake are both tracked even when they are (at least for now?) the same.

@schmoelder
Copy link
Contributor

In hindsight im a little bit confused why n_in_cake and n_cake are both tracked even when they are (at least for now?) the same.

Hmm, they should not be the same. n_in_cake is a stream. so maybe we should consider calling it n_dot_cake_in, whereas n_cake is the cumulative molar amount of the components.

@daklauss
Copy link
Member Author

In hindsight im a little bit confused why n_in_cake and n_cake are both tracked even when they are (at least for now?) the same.

Hmm, they should not be the same. n_in_cake is a stream. so maybe we should consider calling it n_dot_cake_in, whereas n_cake is the cumulative molar amount of the components.

No particles are leaving the cake, so every particle streaming into the cake is part of the cake? It would be more of an issue to use different n if idk some particles react or we would use a more complicated model where cake particles could flow through the membrane statisticly.

@schmoelder
Copy link
Contributor

I don't think so. If n_in = 0, that does not mean that n_cake will probably become 0. It just won't change.

@daklauss
Copy link
Member Author

daklauss commented Mar 19, 2025

$$\dot{n}_{in} = \dot{n}_{feed} \cdot rejection$$

So $n_{in}$ tracks all incoming Particles. $n_{cake}$ is calculated by:

$$\dot{n}_{cake} = \dot{n}_{in}$$

So i guess in our case they are the same. I mean the only difference would be if you would to set the filtercake sectionwise to 0, then $n_{cake}$ would track the current particlecount and $n_{cake}$ the whole.

@daklauss
Copy link
Member Author

daklauss commented Mar 19, 2025

def_filterskizze2 0
Needed a bit to long for this png ... one question is still that $c^{out}_i$ and $c^{PT}_i$ are the same. So do we track them separately or not?

@schmoelder
Copy link
Contributor

one question is still that $c^{out}_i$ and $c^{PT}_i$ are the same.

Yes, they are the same since it's assumed an ideal stirred tank.

So do we track them separately or not?

I's suggest to track them separately. While they are numerically the same, we want to differentiate the unit operation outlet (which is a general interface which should be consistent across all unit operations) and the internal state.

How is this done in the CSTR?

@daklauss
Copy link
Member Author

In the CPS CSTR we have inlet and Bulk and $c^{out}_i$ is the $c_i$ of the bulk. But tbh. i'm not sure how functionable this cstr is. Haven't touched anything beside the DEF in a while. I dont't think this matters to much numerically tbh....

@schmoelder
Copy link
Contributor

then for now, treat it the same.

@daklauss daklauss force-pushed the Add-tracking-of-c/n-in-cake branch 2 times, most recently from ce48358 to 7f15645 Compare March 19, 2025 14:54
@daklauss
Copy link
Member Author

So i kind of reworked state, residual equations and Initialization but it currently fails. Aiming to write the residuals equations later here. IDA is currently not converging.

@schmoelder
Copy link
Contributor

So i kind of reworked state, residual equations and Initialization but it currently fails. Aiming to write the residuals equations later here. IDA is currently not converging.

You need help with that?

@daklauss
Copy link
Member Author

So i kind of reworked state, residual equations and Initialization but it currently fails. Aiming to write the residuals equations later here. IDA is currently not converging.

You need help with that?
Maybe later.

@daklauss daklauss force-pushed the Add-tracking-of-c/n-in-cake branch from 7f15645 to d9dc824 Compare March 20, 2025 10:35
@daklauss daklauss force-pushed the Add-tracking-of-c/n-in-cake branch from d9dc824 to 650259e Compare March 20, 2025 11:06
@daklauss
Copy link
Member Author

daklauss commented Mar 21, 2025

So now a short summary about the residual equations:
Inlet (note that $\tilde{c}_{in}$ is the connection value between uo.):

$$0=c^{in}_i-\tilde{c}^{in}_i$$ $$0 = \dot{n}^{in}_i -Q^{in}\cdot c^{in}_i$$

Retentate (rej is based on the rejection model):

$$0=\dot{n}^R_i - rej_i \cdot \dot{n}^{in}_i$$

mw are molecular weights, $\rho$ is the density

$$0=Q_R - \sum_i \dot{n}^R_i * mw_i / \rho_i$$

if Q_R > 1e-16:

$$0=c^R_i -\dot{n}_i^R / Q^R$$

else:

$$0=c^R_i$$

Permeate:

$$0=\dot{n}^P_i - rej_i \cdot \dot{n}^{in}_i$$ $$0=Q_P - \sum_i \dot{n}^P_i \cdot mw_i / \rho_i$$

if Q_P > 1e-16:

$$0=c^P_i -\dot{n}_i^P / Q^P$$

else:

$$0=c^P_i$$

Cake Equations:

$$0 = V^C - \sum_i n^C \cdot mw_i/ \rho_i$$ $$0=\dot{n}^C_i - \dot{n}^R_i$$

if V^C> 1e-16:

$$0=\dot{c}^C_i -(\dot{n}_i^C - c^C \cdot \dot{V}^C_i ) / V^C$$

else:

$$0=\dot{c}^C_i$$

Permeate tank equations:

$$0 = \dot{c}^PT_i - (\dot{n}^P_i - Q^{out}\cdot c^{PT}_i - \dot{V}^{PT} \cdot c^{PT}_i) / V^{PT}$$ $$0 = \dot{V}^PT - Q^P + Q^{out}$$ $$0 = n^{PT}_i - c^{PT}_i \cdot vol^{PT}$$

Pressue equation:
CV is the volume of a specific component

$$CV_i = n^C_i mw_i / \rho_i$$

$R^C$ is the cake resistance, $\alpha$ is the specific cake resistance:

$$R^C= \sum_i \alpha_i \cdot \rho CV_i$$

so the pressure equations is:
if not np.sum(\dot{n}^P) < 1e-16:

$$0 = \Delta P - \mu \cdot Q^P \cdot (R^M + R^C) / A$$

else:

$$0 = \Delta P$$

This is still work in Progress. I highly doubt, $Q_P$ and $Q_R$ are viable here to use and we have to rely on $V_P$ and $V_R$ and their derivatives, because otherwise the differential index is not 1 ?

@daklauss daklauss force-pushed the Add-tracking-of-c/n-in-cake branch 3 times, most recently from a63040e to 7b3eab8 Compare March 21, 2025 09:28
@daklauss daklauss force-pushed the Add-tracking-of-c/n-in-cake branch 2 times, most recently from 85fea05 to 5b93fc4 Compare March 21, 2025 11:10
@daklauss daklauss force-pushed the Add-tracking-of-c/n-in-cake branch from 5b93fc4 to f73e0ef Compare March 21, 2025 11:12
@daklauss
Copy link
Member Author

Yeah so to sum it up, it seems to converge but wether the solution does make sense or not i can't say yet.

@schmoelder
Copy link
Contributor

Could you please move the figure and the corresponding equations to your first post? That would make it easier to find the relevant information, should we ever need to come back to this PR.

@daklauss
Copy link
Member Author

Could you please move the figure and the corresponding equations to your first post? That would make it easier to find the relevant information, should we ever need to come back to this PR.

Done

@daklauss daklauss merged commit f61eb3b into master Mar 24, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants