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()

[((161, 214), 'numpy.array', 'np.array', (['[y0_Tpos, y0_Tpro, y0_Tneg, y0_o2, y0_test]'], {}), '([y0_Tpos, y0_Tpro, y0_Tneg, y0_o2, y0_test])\n', (169, 214), True, 'import numpy as np\n'), ((213, 237), 'numpy.array', 'np.array', (['[p_o2, p_test]'], {}), '([p_o2, p_test])\n', (221, 237), True, 'import numpy as np\n'), ((240, 316), 'numpy.array', 'np.array', (['[[mu_o2Tpos, mu_o2Tpro, mu_o2Tneg], [mu_testTpos, mu_testTpro, 0]]'], {}), '([[mu_o2Tpos, mu_o2Tpro, mu_o2Tneg], [mu_testTpos, mu_testTpro, 0]])\n', (248, 316), True, 'import numpy as np\n'), ((316, 344), 'numpy.array', 'np.array', (['[lam_o2, lam_test]'], {}), '([lam_o2, lam_test])\n', (324, 344), True, 'import numpy as np\n'), ((348, 385), 'numpy.array', 'np.array', (['[t_DTpos, t_DTpro, t_DTneg]'], {}), '([t_DTpos, t_DTpro, t_DTneg])\n', (356, 385), True, 'import numpy as np\n'), ((386, 420), 'numpy.array', 'np.array', (['[r_Tpos, r_Tpro, r_Tneg]'], {}), '([r_Tpos, r_Tpro, r_Tneg])\n', (394, 420), True, 'import numpy as np\n'), ((425, 471), 'numpy.array', 'np.array', (['[delta_Tpos, delta_Tpro, delta_Tneg]'], {}), '([delta_Tpos, delta_Tpro, delta_Tneg])\n', (433, 471), True, 'import numpy as np\n'), ((474, 514), 'numpy.array', 'np.array', (['[rho_Tpos, rho_Tpro, rho_Tneg]'], {}), '([rho_Tpos, rho_Tpro, rho_Tneg])\n', (482, 514), True, 'import numpy as np\n'), ((517, 725), 'numpy.array', 'np.array', (['[[[l_lim_o2Tpos, u_lim_o2Tpos], [l_lim_o2Tpro, u_lim_o2Tpro], [l_lim_o2Tneg,\n    u_lim_o2Tneg]], [[l_lim_testTpos, u_lim_testTpos], [l_lim_testTpro,\n    u_lim_testTpro], [0, 0]]]'], {'dtype': 'np.float64'}), '([[[l_lim_o2Tpos, u_lim_o2Tpos], [l_lim_o2Tpro, u_lim_o2Tpro], [\n    l_lim_o2Tneg, u_lim_o2Tneg]], [[l_lim_testTpos, u_lim_testTpos], [\n    l_lim_testTpro, u_lim_testTpro], [0, 0]]], dtype=np.float64)\n', (525, 725), True, 'import numpy as np\n'), ((852, 868), 'numpy.empty', 'np.empty', (['[0, 2]'], {}), '([0, 2])\n', (860, 868), True, 'import numpy as np\n'), ((885, 907), 'numpy.arange', 'np.arange', (['(0.1)', '(1)', '(0.2)'], {}), '(0.1, 1, 0.2)\n', (894, 907), True, 'import numpy as np\n'), ((755, 802), 'os.makedirs', 'os.makedirs', (["('../../raw_output/EnvEq/' + f_name)"], {}), "('../../raw_output/EnvEq/' + f_name)\n", (766, 802), False, 'import os\n'), ((928, 950), 'numpy.arange', 'np.arange', (['(0.1)', '(1)', '(0.2)'], {}), '(0.1, 1, 0.2)\n', (937, 950), True, 'import numpy as np\n'), ((1261, 1332), 'EnvEq.solve_eq', 'ee.solve_eq', (['t_max', 'dt', 'y0', 'p', 'mu', 'lam', 'r', 'K', 'delta', 'rho', 'lim', 'f_name_i'], {}), '(t_max, dt, y0, p, mu, lam, r, K, delta, rho, lim, f_name_i)\n', (1272, 1332), True, 'import EnvEq as ee\n'), ((1361, 1368), 'multiprocessing.Pool', 'Pool', (['(4)'], {}), '(4)\n', (1365, 1368), False, 'from multiprocessing import Pool\n'), ((969, 1024), 'numpy.append', 'np.append', (['o2_lim_arr', '[[ulim_Tpro, ulim_Tneg]]'], {'axis': '(0)'}), '(o2_lim_arr, [[ulim_Tpro, ulim_Tneg]], axis=0)\n', (978, 1024), True, 'import numpy as np\n')]