flow.addSource(glycolaldehyde) flow.addSink(glycolaldehyde) flow.addConstraint(inFlow(formaldehyde) == 2) flow.addConstraint(outFlow(glycolaldehyde) == 2) flow.addConstraint(inFlow(glycolaldehyde) == 1) flow.calc() solution = list(flow.solutions)[0] solution.print() flow_graph = HyperGraph.from_flow_solution(solution) ode = dgDynamicSim(flow_graph) stochastic = dgDynamicSim(flow_graph, simulator_choice="stochastic") parameters = {edge: 0.5 for edge in ode.abstract_edges} initial_conditions = { 'Formaldehyde': 100, 'Glycolaldehyde': 1, } drain_parameters = {symbol: { 'out': { 'factor': 0.015 } } for symbol in ode.symbols}
def add_natural_drain(symbols, natural_drain=0.0001): count = 0 for sym in symbols: if sym not in drain_params or 'out' not in drain_params[sym]: drain_params[sym] = {'out': {'factor': natural_drain}} count += 1 print("Natural out drain set to {} for {} reactions".format( natural_drain, count)) parameter_matrix = tuple({ r: rate_dict for r, rate_dict in zip(reactions, generate_rates(reactions)) } for _ in range(runs)) ode = dgDynamicSim(dg) stochastic = dgDynamicSim(dg, 'stochastic') add_natural_drain(ode.symbols) sim_end_time = 60000 period_bounds = (600, sim_end_time / 2) # looking from 600 to 30000 dt = "{:%Y%m%d%H%M%S}".format(datetime.datetime.now()) plot_names_file = "plots_scores_{}_{}_{}_{}.txt".format( file_prefix, plugin_name, method_name, dt) # shot format file that should help in sample classification measurement_output = { 'variance': [], 'fourier_amp': [], 'fourier_freq': [],
recovered_stays_recovered ) initial_conditions = { 'S': 400, 'I': 2, } parameters = { susceptible_infected: 0.001, infected_stays_infected: 0.001, recovered_stays_recovered: 0.001, recovered: 0.03, } ode = dgDynamicSim(dg, simulator_choice="ODE") stochastic = dgDynamicSim(dg, simulator_choice="stochastic") # Name of the data set name = "infected" # figure_size in centimetres figure_size = (40, 20) end_t = 200 with stochastic("spim") as spim: for i in range(3): spim(end_t, initial_conditions, parameters,).plot(figure_size=figure_size) with stochastic("stochkit2") as stochkit2: stochkit2.trajectories = 3 stochkit2.simulate(end_t, initial_conditions, parameters,).plot(figure_size=figure_size)
parameters = { foxes_hunts: 0.005, rabbit_multiples: 0.7, } drain_parameters = { 'F': { 'out': { 'factor': 0.5 } } } end_t = 100 ode = dgDynamicSim(dg, simulator_choice='ode') stochastic = dgDynamicSim(dg, simulator_choice='stochastic') # Name of the data set name = "foxesRabbits" figure_size = (40, 20) scipy = ode('scipy') matlab = ode('matlab') # Run the simulation and give us the output and the analytic class # which gives access to computation of the Fourier transformation etc.. # The output can be inspected and plotted like a normal output class output, analytics = DynamicAnalysisDevice.from_simulation(scipy, end_t, initial_conditions, parameters, drain_parameters)