def scipy_lomnitz2015(par,initial_cond,start_t,end_t,num_steps):
    '''par and initial_cond are dictionaries'''
    
    def model(t,state):
        '''Return derivatives for the model based on the current state. 
        The parameters are derived from the enclosing function.'''
        X1,X2,X3,X4 = state
    
        X1p = a1 * ( (rho1**-1 + (X2/K2A)**2 + rho1**-1*(X4/K4)**2) / (1 + (X2/K2A)**2 + (X4/K4)**2) ) - b1*X1
        X2p = a2*X1 - b2*X2
        X3p = a3*( (rho3**-1 + (X2/K2R)**2) / (1 + (X2/K2R)**2) ) - b3*X3
        X4p = a4*X3-b4*X4

        return [X1p,X2p,X3p,X4p]
    
    # Parameters
    parlist = ['a1','a2','a3','a4','b1','b2','b3','b4','rho1','rho3','K2A','K2R','K4']
    a1,a2,a3,a4,b1,b2,b3,b4,rho1,rho3,K2A,K2R,K4 = [par[k] for k in parlist]

    variables = ['X1','X2','X3','X4']
    initial_cond = [initial_cond[k] for k in variables]
    
    # solve
    t,sys,flag = int_model(model,[],initial_cond,start_t,end_t,num_steps)
            
    # organize for output
    x = {variables[i]:sys[:,i] for i in range(len(sys[0,:]))}

    return (x,t,flag)
def scipy_design_2(par,initial_cond,start_t,end_t,num_steps):
    '''par and initial_cond are dictionaries'''
    
    def model(t,state):
        '''Return derivatives for the model based on the current state. 
        The parameters are derived from the enclosing function.'''
        x,y,z,sx,sy,sz,s = state

        # equations
        clb_free = x + y + z;
        clb_complex = sx + sy + sz;
        
        xdot = v_x - b_x * x - kp * s * x + km * sx - g_yx * x * y - g_zx * x * z + d * sx * clb_free;
        ydot = v_y - b_y * y - kp * s * y + km * sy + a_xy * x + a_yy * y - g_yy * y**2 - g_zy * z * y + d * sy * clb_free;
        zdot = v_z - b_z * z - kp * s * z + km * sz + a_xz * x + a_yz * y + a_zz * z - g_zz * z**2 + d * sz * clb_free;
        
        sxdot = kp * s * x - km * sx - d * sx * clb_free - e * sx;
        sydot = kp * s * y - km * sy - d * sy * clb_free - e * sy;
        szdot = kp * s * z - km * sz - d * sz * clb_free - e * sz;
        
        sdot = v_s - b_s * s - kp * s * clb_free + km * clb_complex;  

        return [xdot,ydot,zdot,sxdot,sydot,szdot,sdot]
    
    # Parameters
    parlist = ['v_x','v_y','v_z','v_s','kp','km','b_x','b_y','b_z','b_s','d','e',
               'a_xy','a_xz','a_yz','a_yy','a_zz',
               'g_yx','g_zx','g_zy','g_yy','g_zz']
    v_x,v_y,v_z,v_s,kp,km,b_x,b_y,b_z,b_s,d,e,\
    a_xy,a_xz,a_yz,a_yy,a_zz,\
    g_yx,g_zx,g_zy,g_yy,g_zz = [par[k] for k in parlist]

    # variables and IC
    variables = ['x','y','z','sx','sy','sz','s']
    initial_cond = [initial_cond[temp] for temp in variables]

    # solve
    t,sys,flag = int_model(model,[],initial_cond,start_t,end_t,num_steps)
            
    # organize for output
    x = {variables[i]:sys[:,i] for i in range(len(sys[0,:]))}

    return (x,t,flag)
def scipy_design_9(par,initial_cond,start_t,end_t,num_steps):
    '''par and initial_cond are dictionaries'''
    
    def model(t,state):
        '''Return derivatives for the model based on the current state. 
        The parameters are derived from the enclosing function.'''
        x,y,z,s = state

        s_free = math.sqrt( ( (1.0/K_A + (x+y+z) - s) / 2.0 )**2.0 + s/K_A ) - ( 1.0/K_A + (x+y+z) - s ) / 2.0 ;
        f = 1.0 / (1.0 + s_free * K_A)
        xdot = v_x - b_x * f * x - e * (1.0-f) * x - g_yx * f**2 * x * y - g_zx * f**2 * x * z ;
        ydot = v_y - b_y * f * y - e * (1.0-f) * y + a_xy * f * x + a_yy * f * y - g_yy * f**2 * y**2 - g_zy * f**2 * z * y ;
        zdot = v_z - b_z * f * z - e * (1.0-f) * z + a_xz * f * x + a_yz * f * y + a_zz * f * z - g_zz * f**2 * z**2 ;

        sdot = v_s * (1 / (1 + s/K_ss))  - b_s * s_free - e * (1.0-f) * (x+y+z) - d * (1.0-f) * (x+y+z) * f * (x + y + z);     

        return [xdot,ydot,zdot,sdot]
    
    # Parameters 
    parlist = ['v_x','v_y','v_z','v_s','K_A','b_x','b_y','b_z','b_s','d','e',
               'a_xy','a_xz','a_yz','a_yy','a_zz',
               'g_yx','g_zx','g_zy','g_yy','g_zz',
               'K_ss']
    v_x,v_y,v_z,v_s,K_A,b_x,b_y,b_z,b_s,d,e,\
    a_xy,a_xz,a_yz,a_yy,a_zz,\
    g_yx,g_zx,g_zy,g_yy,g_zz,\
    K_ss = [par[k] for k in parlist]

    # variables and IC
    variables = ['x','y','z','s']
    initial_cond = [initial_cond[temp] for temp in variables]

    # solve
    t,sys,flag = int_model(model,[],initial_cond,start_t,end_t,num_steps)
            
    # organize for output
    x = {variables[i]:sys[:,i] for i in range(len(sys[0,:]))}

    return (x,t,flag)