from multiprocessing import Pool
import EnvEq as ee
import numpy as np
import itertools as it
import os

#parsing input into numpy arrays
from input import *
y0=np.array([y0_Tpos,y0_Tpro,y0_Tneg,y0_o2,y0_test])
p=np.array([p_o2,p_test])
mu=np.array([[mu_o2Tpos,mu_o2Tpro,mu_o2Tneg],[mu_testTpos,mu_testTpro,0]])
lam=np.array([lam_o2,lam_test])
t_D=np.array([t_DTpos,t_DTpro,t_DTneg])
r=np.array([r_Tpos,r_Tpro,r_Tneg])
delta=np.array([delta_Tpos,delta_Tpro,delta_Tneg])
rho=np.array([rho_Tpos,rho_Tpro,rho_Tneg])
lim=np.array([[[l_lim_o2Tpos,u_lim_o2Tpos],[l_lim_o2Tpro,u_lim_o2Tpro],[l_lim_o2Tneg,u_lim_o2Tneg]],[[l_lim_testTpos,u_lim_testTpos],[l_lim_testTpro,u_lim_testTpro],[0,0]]],dtype=np.float64)

#make directories for saving raw_outputs
try:
    os.makedirs("../../raw_output/EnvEq/"+f_name)
except:
    pass

#iterator over these 
o2_lim_arr=np.empty([0,2])
for ulim_Tpro in np.arange(0.1,1,0.2):
    for ulim_Tneg in np.arange(0.1,1,0.2):
        o2_lim_arr=np.append(o2_lim_arr,[[ulim_Tpro,ulim_Tneg]],axis=0)


def solve_parm(u_lim_o2): #calls the solve_eq function with all default inputs other than o2_lim
    f_name_i=f_name+"{:.1f}".format(u_lim_o2[0])+"-"+"{:.1f}".format(u_lim_o2[1])
    lim[0,1,1]=u_lim_o2[0]
    lim[0,2,1]=u_lim_o2[1]
    ee.solve_eq(t_max,dt,y0,p,mu,lam,r,K,delta,rho,lim,f_name_i)

if __name__ == '__main__':
    pool = Pool(4)
    pool.map(solve_parm,o2_lim_arr) #iterate over the o2_lims
    pool.close()
    pool.join()

[((9, 3, 9, 52), 'numpy.array', 'np.array', ({(9, 12, 9, 51): '[y0_Tpos, y0_Tpro, y0_Tneg, y0_o2, y0_test]'}, {}), '([y0_Tpos, y0_Tpro, y0_Tneg, y0_o2, y0_test])', True, 'import numpy as np\n'), ((10, 2, 10, 25), 'numpy.array', 'np.array', ({(10, 11, 10, 24): '[p_o2, p_test]'}, {}), '([p_o2, p_test])', True, 'import numpy as np\n'), ((11, 3, 11, 74), 'numpy.array', 'np.array', ({(11, 12, 11, 73): '[[mu_o2Tpos, mu_o2Tpro, mu_o2Tneg], [mu_testTpos, mu_testTpro, 0]]'}, {}), '([[mu_o2Tpos, mu_o2Tpro, mu_o2Tneg], [mu_testTpos, mu_testTpro, 0]])', True, 'import numpy as np\n'), ((12, 4, 12, 31), 'numpy.array', 'np.array', ({(12, 13, 12, 30): '[lam_o2, lam_test]'}, {}), '([lam_o2, lam_test])', True, 'import numpy as np\n'), ((13, 4, 13, 39), 'numpy.array', 'np.array', ({(13, 13, 13, 38): '[t_DTpos, t_DTpro, t_DTneg]'}, {}), '([t_DTpos, t_DTpro, t_DTneg])', True, 'import numpy as np\n'), ((14, 2, 14, 34), 'numpy.array', 'np.array', ({(14, 11, 14, 33): '[r_Tpos, r_Tpro, r_Tneg]'}, {}), '([r_Tpos, r_Tpro, r_Tneg])', True, 'import numpy as np\n'), ((15, 6, 15, 50), 'numpy.array', 'np.array', ({(15, 15, 15, 49): '[delta_Tpos, delta_Tpro, delta_Tneg]'}, {}), '([delta_Tpos, delta_Tpro, delta_Tneg])', True, 'import numpy as np\n'), ((16, 4, 16, 42), 'numpy.array', 'np.array', ({(16, 13, 16, 41): '[rho_Tpos, rho_Tpro, rho_Tneg]'}, {}), '([rho_Tpos, rho_Tpro, rho_Tneg])', True, 'import numpy as np\n'), ((17, 4, 17, 190), 'numpy.array', 'np.array', (), '', True, 'import numpy as np\n'), ((26, 11, 26, 26), 'numpy.empty', 'np.empty', ({(26, 20, 26, 25): '[0, 2]'}, {}), '([0, 2])', True, 'import numpy as np\n'), ((27, 17, 27, 37), 'numpy.arange', 'np.arange', ({(27, 27, 27, 30): '(0.1)', (27, 31, 27, 32): '(1)', (27, 33, 27, 36): '(0.2)'}, {}), '(0.1, 1, 0.2)', True, 'import numpy as np\n'), ((21, 4, 21, 49), 'os.makedirs', 'os.makedirs', ({(21, 16, 21, 48): "('../../raw_output/EnvEq/' + f_name)"}, {}), "('../../raw_output/EnvEq/' + f_name)", False, 'import os\n'), ((28, 21, 28, 41), 'numpy.arange', 'np.arange', ({(28, 31, 28, 34): '(0.1)', (28, 35, 28, 36): '(1)', (28, 37, 28, 40): '(0.2)'}, {}), '(0.1, 1, 0.2)', True, 'import numpy as np\n'), ((36, 4, 36, 64), 'EnvEq.solve_eq', 'ee.solve_eq', ({(36, 16, 36, 21): 't_max', (36, 22, 36, 24): 'dt', (36, 25, 36, 27): 'y0', (36, 28, 36, 29): 'p', (36, 30, 36, 32): 'mu', (36, 33, 36, 36): 'lam', (36, 37, 36, 38): 'r', (36, 39, 36, 40): 'K', (36, 41, 36, 46): 'delta', (36, 47, 36, 50): 'rho', (36, 51, 36, 54): 'lim', (36, 55, 36, 63): 'f_name_i'}, {}), '(t_max, dt, y0, p, mu, lam, r, K, delta, rho, lim, f_name_i)', True, 'import EnvEq as ee\n'), ((39, 11, 39, 18), 'multiprocessing.Pool', 'Pool', ({(39, 16, 39, 17): '4'}, {}), '(4)', False, 'from multiprocessing import Pool\n'), ((29, 19, 29, 71), 'numpy.append', 'np.append', (), '', True, 'import numpy as np\n')]