I would like to create a for loop that evaluates multiple inputs for a Cantera Reactor network and gives me the results. The Cantera network runs as a for loop, evaluates a time period, and generates results in numpy arrays then updates those to dataframe. I tried making the Cantera Network For-loop a function, but for some reason it makes the run times exponentially worse. I've noticed this to be a common problem in the Cantera library for other issues.
I want to create a Results Loop that will take inputs and run the Cantera Network For-loop by referencing the cell. Is this feasible? Example code below:
(You shouldn't need to know the Cantera library to help, I just want to specify why using a normal function isn't working).
I've tried this answer but it didn't work: Jupyter Notebook: Run a Notebook cell programmatically within a loop
Cantera network setup
Reactor1 = cantera.Reactor()
Reactor2 = cantera.Reactor()
sim = cantera.ReactorNet([Reactor1, Reactor2)]
Cantera Network For Loop
for i in range(n):
sim.advance(i)
network_array[i] = sim.thermo.P
Results For Loop
inputs = [1,10,100]
for x in range(3):
Reactor1.property = inputs[x]
RUN THE CANTERA NETWORK FOR LOOP CELL
results_array[x] = sim.Property_I_Care_About