Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ports / MCT Model (new PR) #95

Merged
merged 15 commits into from
Aug 14, 2024
10 changes: 5 additions & 5 deletions CADETProcess/modelBuilder/carouselBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ def _add_inter_zone_connections(self, flow_sheet: FlowSheet) -> NoReturn:
origin = unit.outlet_unit
else:
origin = unit
if connections.destinations:
for destination in connections.destinations[None]:
if isinstance(destination, ZoneBaseClass):
destination = destination.inlet_unit

for destination in connections.destinations:
if isinstance(destination, ZoneBaseClass):
destination = destination.inlet_unit

flow_sheet.add_connection(origin, destination)
flow_sheet.add_connection(origin, destination)

for zone in self.zones:
output_state = self.flow_sheet.output_states[zone]
Expand Down
21 changes: 13 additions & 8 deletions CADETProcess/modelBuilder/compartmentBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,19 @@ def validate_flow_rates(self):
flow_rates = self.flow_sheet.get_flow_rates()

for comp in self._real_compartments:
if not np.all(
np.isclose(
flow_rates[comp.name].total_in,
flow_rates[comp.name].total_out
)):
raise CADETProcessError(
f"Unbalanced flow rate for compartment '{comp.name}'."
)
for port in flow_rates[comp.name].total_in:
if not np.all(
np.isclose(
flow_rates[comp.name].total_in[port],
flow_rates[comp.name].total_out[port]
)):
if comp.n_ports == 1:
msg = comp.name
else:
msg = f"{comp.name} at Port {port}"
raise CADETProcessError(
f"Unbalanced flow rate for compartment '{msg}'."
)


class CompartmentModel(Cstr):
Expand Down
30 changes: 29 additions & 1 deletion CADETProcess/processModel/discretization.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class for all other classes in this module and defines some common parameters.
'LRMPDiscretizationFV', 'LRMPDiscretizationDG',
'GRMDiscretizationFV', 'GRMDiscretizationDG',
'WenoParameters', 'ConsistencySolverParameters',
'DGMixin'
'DGMixin',
'MCTDiscretizationFV',
]


Expand Down Expand Up @@ -571,3 +572,30 @@ class ConsistencySolverParameters(Structure):
'solver_name', 'init_damping', 'min_damping',
'max_iterations', 'subsolvers'
]


class MCTDiscretizationFV(DiscretizationParametersBase):
"""Discretization parameters of the FV version of the MCT.

Attributes
----------
ncol : UnsignedInteger, optional
Number of axial column discretization cells. Default is 100.
use_analytic_jacobian : Bool, optional
If True, use analytically computed Jacobian matrix (faster).
If False, use Jacobians generated by algorithmic differentiation (slower).
Default is True.
reconstruction : Switch, optional
Method for spatial reconstruction. Valid values are 'WENO' (Weighted
Essentially Non-Oscillatory). Default is 'WENO'.

"""

ncol = UnsignedInteger(default=100)
use_analytic_jacobian = Bool(default=True)
reconstruction = Switch(default='WENO', valid=['WENO'])

_parameters = [
'ncol', 'use_analytic_jacobian', 'reconstruction',
]
_dimensionality = ['ncol']
Loading