Created
October 9, 2024 14:50
-
-
Save AntoniaBerger/bf5224a53c0caa433f60838647232771 to your computer and use it in GitHub Desktop.
Slow CSTR depens on the ration of volume to inlet concentration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from CADETProcess.processModel import ComponentSystem, Inlet, Outlet, Cstr, FlowSheet | |
from CADETProcess.processModel import LRMDiscretizationFV, Process,LRMDiscretizationDG | |
from CADETProcess.simulator import Cadet, SolverTimeIntegratorParameters | |
from CADETProcess.processModel import LumpedRateModelWithoutPores | |
from CADETProcess.processModel import Langmuir, Linear | |
import math | |
import time | |
component_system = ComponentSystem(['a']) | |
# Anzahl der zu erstellenden CSTRs und LRM | |
num_cstrs = 5 | |
# Listen für CSTRs und LRM | |
cstrs = dict() | |
InletCSTR = Inlet(component_system,'inletCSTR') | |
InletCSTR.flow_rate = 0.03 | |
# Erstelle CSTRs und LRM in einer Schleife | |
for i in range(num_cstrs): | |
name=f'cstr{i}' | |
cstr = Cstr(component_system,name ) | |
cstr.c = [0] | |
cstr.V = 1e-3 | |
cstr.porosity = 0.33 | |
cstrs[name] = cstr | |
outlet_CSTR = Outlet(component_system,'outletCSTR') | |
flow_sheet_CSTR = FlowSheet(component_system) | |
for i in cstrs.keys(): | |
flow_sheet_CSTR.add_unit(cstrs[i]) | |
flow_sheet_CSTR.add_unit(InletCSTR) | |
flow_sheet_CSTR.add_unit(outlet_CSTR) | |
flow_sheet_CSTR.add_connection(InletCSTR,cstrs[f'cstr{0}']) | |
for i in range(0,num_cstrs-1): | |
flow_sheet_CSTR.add_connection(cstrs[f'cstr{i}'],cstrs[f'cstr{i+1}']) | |
flow_sheet_CSTR.add_connection(cstrs[f'cstr{num_cstrs-1}'],outlet_CSTR) | |
concentrations = [1e-5, 1e-4, 1e-3, 1.0001e-3, 1.001e-3, 1.01e-3, 1.1e-3] | |
durations = [] | |
for concentration in concentrations: | |
process_CSTR = Process(flow_sheet_CSTR, 'process_CSTR') | |
process_CSTR.cycle_time = 500*60 | |
_ = process_CSTR.add_event('start load LR', 'flow_sheet.inletCSTR.c', [concentration], 0) | |
_ = process_CSTR.add_event('stop load LR', 'flow_sheet.inletCSTR.c', [0],1/0.03*60) | |
process_simulator = Cadet() | |
process_simulator.save_to_h5(process_LRM, f'TestFiles/LRMSystem{num_lrms}.h5') | |
process_simulator.n_cycles = 10 | |
time_start = time.time() | |
simulation_results_CSTR = process_simulator.simulate(process_CSTR) | |
time_end = time.time() | |
print("Laufzeit CSTR:", time_end-time_start) | |
durations.append(simulation_results_CSTR.time_elapsed) | |
from matplotlib import pyplot as plt | |
fig, ax = plt.subplots() | |
ax.plot(concentrations, durations) | |
ax.set_xscale('log') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment