Skip to content

Commit

Permalink
finalbachelorversion
Browse files Browse the repository at this point in the history
  • Loading branch information
daklauss committed Oct 11, 2024
1 parent f72f852 commit a1c270a
Showing 1 changed file with 14 additions and 38 deletions.
52 changes: 14 additions & 38 deletions CADETPythonSimulator/unit_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ class DeadEndFiltration(UnitOperationBase):
permeate_tank = {
'dimensions': (),
'entries': {
'n_permeate_tank': 'n_comp',
# 'n_permeate_tank': 'n_comp',
'c': 'n_comp',
'tankvolume': 1
},
Expand Down Expand Up @@ -844,8 +844,8 @@ def compute_residual(
c_tank = self.states['permeate_tank']['c']
c_tank_dot = self.state_derivatives['permeate_tank']['c']

n_tank = self.states['permeate_tank']['n_permeate_tank']
n_tank_dot = self.state_derivatives['permeate_tank']['n_permeate_tank']
# n_tank = self.states['permeate_tank']['n_permeate_tank']
# n_tank_dot = self.state_derivatives['permeate_tank']['n_permeate_tank']

tankvolume = self.states['permeate_tank']['tankvolume']
tankvolume_dot = self.state_derivatives['permeate_tank']['tankvolume']
Expand Down Expand Up @@ -897,7 +897,7 @@ def compute_residual(
cakresistance = \
np.sum(specific_cake_resistance * densities * cake_vol/membrane_area)

if not np.sum(n_permeate_dot) < 1e-13:
if not np.sum(n_permeate_dot) < 1e-16:
viscositiy = \
np.exp(np.sum(n_permeate_dot* np.log(viscosities)) / np.sum(n_permeate_dot))

Check failure on line 902 in CADETPythonSimulator/unit_operation.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

CADETPythonSimulator/unit_operation.py:902:89: E501 Line too long (92 > 88)

Expand All @@ -907,30 +907,16 @@ def compute_residual(
else:
self.residuals['cake']['pressure'] = deltap

# ni in the tank
self.residuals['permeate_tank']['n_permeate_tank'] =\
n_tank_dot - n_permeate_dot + Q_out * c_tank

# Tank equations

res = np.ndarray(c_tank.shape)

for i, n_tank_i in enumerate(n_tank):
if n_tank_i < 1e-13:
if n_permeate_dot[i] > 1e-13:
weight = np.sum(n_permeate_dot*molecular_weights)
res[i] =\
c_tank[i] - n_permeate_dot[i] * densities[i] / weight
else:
res[i] = c_tank[i]
else:
weight = np.sum(n_tank*molecular_weights)
res[i] = c_tank[i] - n_tank_i * densities[i] / weight
c_tank_dot_new =\
(n_permeate_dot - Q_out * c_tank - tankvolume_dot * c_tank) / tankvolume

self.residuals['permeate_tank']['c'] = res
self.residuals['permeate_tank']['c'] = c_tank_dot - c_tank_dot_new

self.residuals['permeate_tank']['tankvolume'] =\
tankvolume - np.sum(n_tank * molecular_weights / densities)
tankvolume_dot - permeate_vol_dot + Q_out



@property
Expand Down Expand Up @@ -1028,25 +1014,15 @@ def initialize_initial_values(self, t_zero: float):

c_tank = self.states['permeate_tank']['c']
tankvolume = self.states['permeate_tank']['tankvolume']
tankvolume_dot = permeate_vol_dot - Q_out

n_tank = self.states['permeate_tank']['n_permeate_tank']
n_tank_dot = n_permeate_dot - Q_out * c_tank
c_tank_dot =\
(n_permeate_dot - Q_out * c_tank - tankvolume_dot * c_tank) / tankvolume

for i, n_tank_i in enumerate(n_tank):
if n_tank_i < 1e-13:
if n_permeate_dot[i] > 1e-13:
weight = np.sum(n_permeate_dot*molecular_weights)
c_tank[i] =\
n_permeate_dot[i] * densities[i] / weight
else:
weight = np.sum(n_tank*molecular_weights)
c_tank[i] = n_tank_i * densities[i] / weight
self.state_derivatives['permeate_tank']['c'] = c_tank_dot

self.state_derivatives['permeate_tank']['n_permeate_tank'] = n_tank_dot
self.states['permeate_tank']['c'] = c_tank
self.state_derivatives['permeate_tank']['tankvolume'] = tankvolume_dot

self.states['permeate_tank']['tankvolume'] =\
np.sum(n_tank * molecular_weights / densities)



Expand Down

0 comments on commit a1c270a

Please sign in to comment.