sys.add_connection(z1, z2) sys.add_connection(z2, z3) sys.add_connection(z3, z0) f_42 = 1.4e-7 f_45 = 7.66e-7 w_r = f_42 / (f_42 + f_45) f_63 = 1.54e-7 f_67 = 8.08e-7 w_e = f_63 / (f_63 + f_67) sys.set_output_state(z0, [w_r, 1 - w_r]) sys.set_output_state(z2, [w_e, 1 - w_e]) sys.switch_time = 180 fs = sys.build_flow_sheet() proc = sys.build_process() from CADETProcess.simulation import Cadet process_simulator = Cadet( cadet_bin_path='/home/jo/software/cadet/cadet4.2.0/bin/', temp_dir='/dev/shm') process_simulator.evaluate_stationarity = True process_simulator.n_cycles = 1 process_simulator.solver_parameters.NTHREADS = 1 proc_results = process_simulator.simulate(proc, file_path='new.h5')
ssr_binary.add_event('recycle_on', 'flow_sheet.column.output_state', 0) ssr_binary.add_event('recycle_off', 'flow_sheet.column.output_state', 1) ssr_binary.add_event_dependency('feed_on', ['inject_off']) ssr_binary.add_event_dependency('feed_off', ['feed_on', 'feed_duration'], [1, 1]) ssr_binary.add_event_dependency( 'inject_off', ['inject_on', 'feed_duration', 'recycle_off', 'recycle_on'], [1, 1, 1, -1]) # Set process times ssr_binary.cycle_time = 191.11 ssr_binary.feed_duration.time = 42.956 ssr_binary.recycle_on.time = 354.081 ssr_binary.recycle_off.time = 358.552 if __name__ == '__main__': from CADETProcess.simulation import Cadet process_simulator = Cadet() process_simulator.evaluate_stationarity = True process_simulator.n_cycles_min = 4 ssr_binary_sim_results = process_simulator.simulate(ssr_binary) ssr_binary_sim_results.save(case_dir) from CADETProcess.fractionation import optimize_fractionation ssr_binary_frac = optimize_fractionation( ssr_binary_sim_results.chromatograms, ssr_binary.process_meta, purity_required=0.95) ssr_binary_frac.save(case_dir)
def simulate_solid_equilibria(binding_model, buffer, unit_model='cstr', flush=None): process_name = flow_sheet_name = 'initial_conditions' component_system = binding_model.component_system # Unit Operations buffer_source = Source(component_system, name='buffer') buffer_source.c = buffer if flush is None: flush = buffer flush_source = Source(component_system, 'flush') flush_source.c = flush if unit_model == 'cstr': unit = Cstr(component_system, 'cstr') unit.porosity = 0.5 unit.V = 1e-6 Q = 1e-6 cycle_time = 1000 * unit.volume / Q unit.flow_rate = Q elif unit_model == 'column': unit = LumpedRateModelWithoutPores(component_system, name='column') unit.length = 0.1 unit.diameter = 0.01 unit.axial_dispersion = 1e-6 unit.total_porosity = 0.7 Q = 60 / (60 * 1e6) cycle_time = 10 * unit.volume / Q try: q = binding_model.n_comp * binding_model.n_states * [0] q[0] = binding_model.capacity unit.q = q except AttributeError: pass unit.binding_model = binding_model outlet = Sink(component_system, name='outlet') # flow sheet fs = FlowSheet(component_system, name=flow_sheet_name) fs.add_unit(buffer_source) fs.add_unit(flush_source) fs.add_unit(unit) fs.add_unit(outlet, chromatogram_sink=True) fs.add_connection(buffer_source, unit) fs.add_connection(flush_source, unit) fs.add_connection(unit, outlet) # Process proc = Process(fs, name=process_name) proc.cycle_time = cycle_time ## Create Events and Durations proc.add_event('buffer_on', 'flow_sheet.buffer.flow_rate', Q) proc.add_event('buffer_off', 'flow_sheet.buffer.flow_rate', 0, 0.9 * cycle_time) proc.add_event('eluent_off', 'flow_sheet.flush.flow_rate', 0.0, 0.0) proc.add_event('eluent_on', 'flow_sheet.flush.flow_rate', Q, 0.9 * cycle_time) # Simulator process_simulator = Cadet() process_simulator.unit_return_parameters.write_solution_bulk = True process_simulator.unit_return_parameters.write_solution_solid = True proc_results = process_simulator.simulate(proc) if unit_model == 'cstr': init_q = proc_results.solution[unit.name].solid.solution[-1, :] elif unit_model == 'column': init_q = proc_results.solution[unit.name].solid.solution[-1, 0, :] return init_q.tolist()