def calculateTs_Kolmogorov_BVP(alpha, beta, tauchar = 1.0, xth= 1.0, xmin = -1.0): D = beta*beta /2. def dS(S,x): return -( (alpha-x/tauchar)/D ) * S -1.0/D; S_0 = .0; xs = linspace(xmin, xth, 1000); dx = (xs[1]-xs[0]) Ss = odeint(dS, S_0, xs); if max(Ss) > .0: raise RuntimeError('Ss should be negative') T1s = -cumsum(Ss[-1::-1]) * dx T1s = T1s[-1::-1] T1_interpolant = interp1d(xs, T1s, bounds_error=False, fill_value = T1s[-1]); def dS2(S,x): T1 = T1_interpolant(x) return -( (alpha-x/tauchar)/D ) * S -2.0*T1/D; Ss = odeint(dS2, S_0, xs); if max(Ss) > .0: raise RuntimeError('Ss should be negative') T2s = -cumsum(Ss[-1::-1]) * dx T2s = T2s[-1::-1] return xs, T1s, T2s
def main(): t = arange(0.0, 100.0, 2 * pi / 10.) t_ = t[0::10] #select every 10th, there t=2*pi*n for i in range(1): #compute 100 trajectories q_init = pi / 4. Q_init = 0.0001 p_init = 0.0001 #rnd.random()*2*pi P_init = 1 x_init = array([q_init, Q_init, p_init, P_init]) x = oiL.odeint(derivative, x_init, t) #Q = [arctan2(sin(i[1]),cos(i[1])) for i in x] q = [i[0] for i in x] Q = [i[1] for i in x] p = [i[2] for i in x] P = [i[3] for i in x] print x[0, :] print x[-1, :] pl.plot(t, q, '.') #pl.plot(q[0::10], p[0::10], '.') #only plot evert 10th item, there t=2pi*n pl.xlabel('q') pl.ylabel('p') pl.show()
def compute_trajectory(y0): """ Integrate the ODE for the initial point y0 = [phi_0, v_0] """ t = arange(0.0, 100.0, 0.1) # array of times y_t = oiL.odeint(derivative, y0, t) # integration of the equation return y_t # return arrays for phi and v
def main(): """ Plots the trajectories of 3 equal masses forming a figure 8. """ # initial positions ip1 = [0.97000436, -0.24308753] ip2 = [-ip1[0], -ip1[1]]; ip3 = [0, 0] # initial velocities iv3 = [-0.93240737, -0.86473146] iv2 = [-iv3[0]/2, -iv3[1]/2]; iv1 = iv2 # input for initial righthandside vector initz = [ip1[0], iv1[0], ip1[1], iv1[1], \ ip2[0], iv2[0], ip2[1], iv2[1], \ ip3[0], iv3[0], ip3[1], iv3[1]] # solving the IVP T = 2*sp.pi/3; n = 1000 tspan = sp.linspace(0,T,n+1) z = odeint(f,initz,tspan) # extracing the trajectories x1 = z[:,0]; y1 = z[:,2] x2 = z[:,4]; y2 = z[:,6] x3 = z[:,8]; y3 = z[:,10]; # plotting the trajectories fig = plt.figure() plt.plot(x1,y1,'r',x2,y2,'g',x3,y3,'b') plt.show()
def compute_trajectory(y0): """ Integrate the ODE for the initial point y0 = [phi_0, v_0] """ t = arange(0.0, 1.0, 0.01) # array of times y_t = oiL.odeint(derivative, y0, t) # integration of the equation return y_t[:, 0], y_t[:, 1] # return arrays for phi and v
def main(): t = arange(0.0, 100.0, 2*pi/10.) t_ = t[0::10] #select every 10th, there t=2*pi*n for i in range(1): #compute 100 trajectories q_init = pi/4. Q_init = 0.0001 p_init = 0.0001 #rnd.random()*2*pi P_init = 1 x_init = array([q_init, Q_init, p_init, P_init]) x = oiL.odeint(derivative, x_init, t) #Q = [arctan2(sin(i[1]),cos(i[1])) for i in x] q = [i[0] for i in x] Q = [i[1] for i in x] p = [i[2] for i in x] P = [i[3] for i in x] print x[0,:] print x[-1,:] pl.plot(t, q, '.') #pl.plot(q[0::10], p[0::10], '.') #only plot evert 10th item, there t=2pi*n pl.xlabel('q') pl.ylabel('p') pl.show()
def abcodeint_onestep(func, current_concentrations, t1, t2, parameters, dt=0.01, atol=None, rtol=None): time = t1 next_time = min(time + dt, t2) current_concentrations, parameters = func.rules(current_concentrations, parameters, time) while 1: # print time, next_time, t2, current_concentrations data = odeint(func.modelfunction, current_concentrations, [time, next_time], args=(parameters, ), atol=atol, rtol=rtol) current_concentrations, parameters = func.rules( current_concentrations, parameters, next_time) current_concentrations = data[1] if (t2 - next_time) < 0.000000001: return [current_concentrations, next_time, True] time = next_time next_time = min(time + dt, t2) return [current_concentrations, time, False]
def createSimulation(self): X, infodict = odeint( self.dX_dt, self.initialCondition, self.time, full_output=True, Dfun=self.d2X_dt2, ) return X
def next_step(self): #print self.state, [self.t, self.t + self.dt] newstate = oiL.odeint(self.derr, self.state, [self.t, self.t + self.dt]) self.state = newstate[1] self.t += self.dt finished = self.t >= self.t_end return [ self.state, finished ]
def main(): qx_init = 0. qy_init = 0. px_init = .50 py_init = -.50 x_init = array([qx_init, qy_init, px_init, py_init]) t = linspace(0.0, 20.0, 1000) x_nrel = oiL.odeint(derr_nrel, x_init, t) t = linspace(0.0, 20.0, 1000) x_rel = oiL.odeint(derr_rel, x_init, t) pl.plot(x_nrel[:,0], x_nrel[:,1]) pl.plot(x_rel[:,0], x_rel[:,1]) pl.show()
def runModel(self, tspan, vary = False): ''' Runs the ODE model for the system ''' if vary: # self.y0 = self.varyVector(self.init) self.y0 = self.init self.p = self.varyVector(self.params) else: self.y0 = self.init self.p = self.params return odeint(self.diffEQs, self.y0, tspan, (self.p, 'annoyingly necessary value'))
def main(): """ Defines the setup for the system for the trailer and solves it. """ T = 20; n = 100 tspan = sp.linspace(0,T,n+1) initc = sp.array([2,0]) path = odeint(trailer,initc,tspan) x = path[:,0]; y = path[:,1] x1, x2, x1v, x2v = tractor(tspan) fig = plt.figure() plt.plot(x1,x2,'r',x,y,'g') for i in xrange(0,n,6): plt.plot(sp.array([x1[i],x[i]]), \ sp.array([x2[i],y[i]]),'b') plt.show()
def denbigh_rxn2(input_features, A=[.2, 0.01, 0.005, 0.005], E=[7000, 3000, 3000, 100]): ''' Returns output concentration for a batch reactor based on the denbigh reaction. Reaction parameters has been tuned to ensure variability within default trans range :param input_features: Features class object containing features information. Last 2 column must be time and temperature. First n columns represent n species initial concentration :param A: Pre-Exponent factor for Arrhenius Equation :param E: Activation Energy :param plot_mode: Plot conc vs time graph for last set of features if == True :return: Label class containing output concentrations of A,R,T,S,U ''' numel_row = input_features.shape[0] numel_col = input_features.shape[1] conc = input_features[:, :numel_col - 2] c_out = [] def reaction(c, t, T, A, E): # Rate equations for Denbigh reaction from Chemical Reaction Engineering, Levenspiel 3ed Chapter 8, page 194 [Ca, Cr, Ct, Cs, Cu] = c [k1, k2, k3, k4] = A * np.exp(-np.array(E) / (8.314 * T)) [dCadt, dCrdt, dCtdt, dCsdt, dCudt] = [ -(k1 + k2) * Ca**2, k1 * Ca**2 - (k3 + k4) * Cr**0.5, k2 * Ca**2, k3 * Cr**0.5, k4 * Cr**0.5 ] return [dCadt, dCrdt, dCtdt, dCsdt, dCudt] if numel_col < 7: # If input_features has less than 7 columns, means not all species have non zero inital conc. Must add zero cols zeros = np.zeros((numel_row, 7 - numel_col)) input_features = np.concatenate((conc, zeros, input_features[:, -2:]), axis=1) for i in range(numel_row): c0 = input_features[i, :-2] t = np.linspace(0, input_features[i, -2], 2000) T = input_features[i, -1] c = odeint(reaction, c0, t, args=(T, A, E)) c_out.append(c[-1, :]) c_out = np.array( c_out) # To convert list of numpy array to n x m numpy array return c_out
def main(): n_traj = 50 t = arange(0.0, 100.0, 2 * pi / 10.) t_ = t[0::10] #select every 10th, there t=2*pi*n pl.figure() pl.subplot(311) pl.xlabel('t') pl.ylabel('q') pl.subplot(312) pl.xlabel('q') pl.ylabel('p') pl.subplot(313) pl.xlabel('q @t=2*pi*n (every 10th)') pl.ylabel('p @t=2*pi*n (every 10th)') for i in range(n_traj): #compute n_traj trajectories q_init = 0 p_init = linspace(-2, 2, n_traj)[i] #rnd.random()*4-2 x_init = array([q_init, p_init]) x = oiL.odeint(derivative, x_init, t) q = [arctan2(sin(i[0]), cos(i[0])) for i in x] #q = [i[0] for i in x] p = [i[1] for i in x] #print x[0,:] #print x[-1,:] pl.subplot(311) pl.plot(t, q, '.') pl.subplot(312) pl.plot(q, p, '.') pl.subplot(313) pl.plot(q[0::10], p[0::10], '.') #only plot evert 10th item, there t=2pi*n pl.show()
def exportTrajectoriesFigToPNG(self, filename): # values = linspace(0.3, 0.9, 5) # position of X0 between X_f0 and X_f1 # vcolors = p.cm.autumn_r(linspace(0.3, 1., len(values))) # colors for each trajectory f2 = p.figure() # ------------------------------------------------------- # plot trajectories #for v, col in zip(values, vcolors): X0 = self.X_f1 # starting point X = odeint(self.dX_dt, self.initialCondition, self.time) # we don't need infodict here p.plot(X[:, 0], X[:, 1], lw=3.5, label='X0=(%.f, %.f)' % (self.initialCondition[0], self.initialCondition[1])) p.plot(X0[0], X0[1], 'b.') p.plot(self.X_f1[0], self.X_f1[1], 'r.') # ------------------------------------------------------- # define a grid and compute direction at each point ymax = p.ylim(ymin=0)[1] # get axis limits xmax = p.xlim(xmin=0)[1] nb_points = 30 x = np.linspace(0, xmax, nb_points) y = np.linspace(0, ymax, nb_points) X1, Y1 = p.meshgrid(x, y) # create a grid DX1, DY1 = self.dX_dt([X1, Y1]) # compute growth rate on the gridt M = (p.hypot(DX1, DY1)) # Norm of the growth rate M[M == 0] = 1. # Avoid zero division errors DX1 /= M # Normalize each arrows DY1 /= M p.title('Trajectories and direction fields') p.quiver(X1, Y1, DX1, DY1, M, pivot='mid') p.xlabel('Number of rabbits') p.ylabel('Number of foxes') p.legend() p.grid() p.xlim(0, xmax) p.ylim(0, ymax) f2.savefig(filename)
def abcodeint_onestep(func, current_concentrations, t1, t2, parameters, dt=0.01, atol=None, rtol=None): time = t1 next_time = min(time+dt,t2) current_concentrations,parameters=func.rules(current_concentrations, parameters, time) while 1: #print time, next_time, t2, current_concentrations data = odeint(func.modelfunction, current_concentrations, [time, next_time], args=(parameters,), atol=atol, rtol=rtol ) current_concentrations, parameters = func.rules(current_concentrations, parameters, next_time) current_concentrations = data[1] if ((t2 - next_time)<0.000000001): return [ current_concentrations, next_time, True ] time = next_time next_time = min(time+dt,t2) return [ current_concentrations, time, False ]
def main(): """ Plots the trajectories of 3 equal masses forming a figure 8. """ # initial positions ip1 = [0.97000436, -0.24308753] ip2 = [-ip1[0], -ip1[1]]; ip3 = [0, 0] # initial velocities iv3 = [-0.93240737, -0.86473146] iv2 = [-iv3[0]/2, -iv3[1]/2]; iv1 = iv2 # input for initial righthandside vector initz = [ip1[0], iv1[0], ip1[1], iv1[1], \ ip2[0], iv2[0], ip2[1], iv2[1], \ ip3[0], iv3[0], ip3[1], iv3[1]] # solving the IVP T = 2*sp.pi/3; n = 1000 tspan = sp.linspace(0,T,n+1) z = odeint(f,initz,tspan) animate(z,30)
def main(): """ Computes the motion of a pendulum, governed by the ODE: theta''(t) + alpha*sin(theta(t)) = 0, """ T = 10; n = 1000 theta0 = sp.pi/6; v0 = 0 tspan = sp.linspace(0,T,n+1) initc = sp.array([theta0,v0]) y = odeint(f,initc,tspan) theta = y[:,0] v = y[:,1] fig = plt.figure() fig.add_subplot(211) plt.plot(tspan,theta) plt.title('angle as function of time') fig.add_subplot(212) plt.plot(tspan,v,label='velocity(t)') plt.title('velocity as function of time') plt.show()
def exportTrajectoriesFigToPNG(self, filename): f2 = p.figure() X0 = self.X_f1 # starting point X = odeint(self.dX_dt, self.initialCondition, self.time) # we don't need infodict here p.plot(X[:, 0], X[:, 1], lw=3.5, label='X0=(%.f, %.f)' % (self.initialCondition[0], self.initialCondition[1])) # p.plot(X0[0], X0[1], 'b.') # p.plot(self.X_f2[0], self.X_f2[1], 'r.') # ------------------------------------------------------- # define a grid and compute direction at each point ymax = p.ylim(ymin=0)[1] # get axis limits xmax = p.xlim(xmin=0)[1] #nb_points = 30 # x = np.linspace(0, xmax, nb_points) # y = np.linspace(0, ymax, nb_points) # # X1, Y1 = p.meshgrid(x, y) # create a grid # DX1, DY1 = self.dX_dt([X1, Y1]) # compute growth rate on the gridt # M = (p.hypot(DX1, DY1)) # Norm of the growth rate # M[M == 0] = 1. # Avoid zero division errors # DX1 /= M # Normalize each arrows # DY1 /= M p.title('Trajectories and direction fields') #p.quiver(X1, Y1, DX1, DY1, M, pivot='mid') p.xlabel('Number of rabbits') p.ylabel('Number of foxes') p.legend() p.grid() p.xlim(0, xmax) p.ylim(0, ymax) f2.savefig(filename)
def solve(self, t=None, is_plot_curve: bool = True, is_plot_phase_orbit: bool = True) -> tuple: """ 求解种群竞争问题 Parameters ---------- t : 1 dim array_like 时间向量 is_plot_curve : bool 是否绘制种群生长曲线 is_plot_phase_orbit : bool 是否绘制相轨图 Returns ------- t : `~np.ndarray` 1维时间向量 x1 : `~np.ndarray` 种群1的数量数组 x2 : `~np.ndarray` 种群2的数量数组 """ self.t = np.arange(0, 20, 0.02) if t is None else np.array(t) self.x_list = odeint(self.__deriv, [self.x10, self.x20], self.t) # type:np.ndarray self.x1 = self.x_list[:, 0] self.x2 = self.x_list[:, 1] # 绘制曲线 if is_plot_curve: self.plotPopulationCurve() if is_plot_phase_orbit: self.plotPhaseOrbitDiagram() return (self.t, self.x1, self.x2)
def exportTrajectoriesFigToPNG(self, filename): f2 = p.figure() X0 = self.X_f1 X = odeint(self.dX_dt, self.initialCondition, self.time) p.plot(X[:, 0], X[:, 1], lw=3.5, label='X0=(%.f, %.f)' % (self.initialCondition[0], self.initialCondition[1])) ymax = p.ylim(ymin=0)[1] xmax = p.xlim(xmin=0)[1] nb_points = 30 p.title('Trajectories and direction fields') p.xlabel('Number of rabbits') p.ylabel('Number of foxes') p.legend() p.grid() p.xlim(0, xmax) p.ylim(0, ymax) f2.savefig(filename)
def exportTrajectoriesFigToPNG(self, filename: str): f2 = p.figure() X0 = self.X_f1 X = odeint(self.dX_dt, self.initialCondition, self.time) p.plot(X[:, 0], X[:, 1], lw=3.5, label='X0=(%.f, %.f)' % (self.initialCondition[0], self.initialCondition[1])) p.plot(X0[0], X0[1], 'b.') p.plot(self.X_f1[0], self.X_f1[1], 'r.') ymax = p.ylim(ymin=0)[1] xmax = p.xlim(xmin=0)[1] nb_points = 30 x = np.linspace(0, xmax, nb_points) y = np.linspace(0, ymax, nb_points) X1, Y1 = p.meshgrid(x, y) DX1, DY1 = self.dX_dt([X1, Y1]) M = (p.hypot(DX1, DY1)) M[M == 0] = 1. DX1 /= M DY1 /= M p.title('Trajectories and direction fields') p.quiver(X1, Y1, DX1, DY1, M, pivot='mid') p.xlabel('Number of rabbits') p.ylabel('Number of foxes') p.legend() p.grid() p.xlim(0, xmax) p.ylim(0, ymax) f2.savefig(filename)
def abcodeint(func, init_values, timepoints, parameters, dt=0.01, atol=None, rtol=None): """Call scipy.integrate.odeint. Return values for each species whose trajectory is described by func at timepoints given by timepoints. ***** args ***** func: a function to integrate, generated by parseInfo.py from an SBML model. InitValues: a list of floats representing the initial values of the species whose trajectories are described by func. timepoints: a list of times at which values for the spec are required. parameters: a tuple of parameters to pass to func ***** kwargs ***** dt: Internal timestep. scipy.integrate.odeint is forced to calculate values at this interval. For a stiff model a small dt is required for successful simulation. rtol: relative error tolerance. For a stiff model a small relative error tolerance is required for a successful simulation. atol: absolute error tolerance. For a stiff model a small absolute error tolerance is required for a successful simulation. """ # array for the data that the user wants solutions_out = numpy.zeros([len(timepoints), len(init_values)]) current_concentrations = tuple(init_values) # current_concentrations,parameters=func.rules(current_concentrations, parameters, timepoints[0]) current_concentrations, parameters = func.rules(current_concentrations, parameters, 0) solutions_out[0] = current_concentrations counter = 0 # 1 flag = True # intTime1 = timepoints[0] int_time1 = 0 while flag: int_time2 = min(int_time1 + dt, timepoints[counter]) data = odeint(func.modelfunction, current_concentrations, [int_time1, int_time2], args=(parameters, ), atol=atol, rtol=rtol) data[1], parameters = func.rules(data[1], parameters, int_time2) if (timepoints[counter] - int_time2) < 0.000000001: solutions_out[counter] = data[1] counter += 1 if counter == len(timepoints): flag = False current_concentrations = data[1] int_time1 = int_time2 return solutions_out
def evaluate(self, math_model): math_model.result = odeint(math_model.model, math_model.Y, math_model.T)
def main(): Omega = 1 bz = BelousovZhabotinskii(Omega) #u0 = bz.max_u() u0 = bz.u_stationary()*2 v0 = bz.v_stationary() y0 = [u0,v0] max_t = 10.0 t = np.arange(0,max_t,0.0001) u_nullcline = np.logspace(-4, 0, 100000)*Omega v_nullclines = bz.nullcline(u_nullcline) y = odeint(bz.dy_dt,y0,t) plt.Figure() plt.plot(u_nullcline, v_nullclines[0]) plt.plot(u_nullcline, v_nullclines[1]) plt.plot(y[:,0],y[:,1]) plt.loglog() plt.xlim([5e-5*Omega,2e0*Omega]) #plt.show() plt.savefig("bz_wave_phase_plot.png") plt.clf() plt.plot(t,y[:,0]) plt.plot(t,y[:,1]) plt.plot(t,bz.w(y[:,0],y[:,1])) plt.yscale('log') plt.xlim((0,5)) #plt.show() plt.savefig("bz_wave_concen_versus_time.png") plt.clf() h = 0.001 x = np.arange(0,20,h) u0 = zeros_like(x) + bz.u_stationary() v0 = zeros_like(x) + bz.v_stationary() u0[x<1] = bz.u_stationary()*2 y = np.vstack((u0,v0)) if 1: dt = 0.0000001 iterations = int(max_t/dt) out_every = iterations/1000 #out_every = 1000 #plt.ion() plot_u, = plt.plot(x,u0) plot_v, = plt.plot(x,v0) plt.yscale('log') plt.ylim((bz.u_stationary()/10,bz.max_u())) #plt.show() dydt_old = bz.dy_dt_diffuse(y, t, h) for i in range(0,iterations): t = i*dt if (i%out_every == 0): plot_u.set_ydata(y[0,:]) plot_v.set_ydata(y[1,:]) #plt.draw() plt.savefig("bz_wave_" + '%04d'%i + ".png") dydt = bz.dy_dt_diffuse(y, t, h) #y = y + dt*dydt y = y + 3.0/2.0*dt*dydt - 0.5*dt*dydt_old dydt_old = dydt
def solve(self): return oiL.odeint(self.derr, self.init, arange(self.t_start, self.t_end, self.dt))
def abcodeint(func, InitValues, timepoints, parameters, dt=0.01, atol=None, rtol=None): """Call scipy.integrate.odeint. Return values for each species whose trajectory is described by func at timepoints given by timepoints. ***** args ***** func: a function to integrate, generated by parseInfo.py from an SBML model. InitValues: a list of floats representing the initial values of the species whose trajectories are described by func. timepoints: a list of times at which values for the spec are required. parameters: a tuple of parameters to pass to func ***** kwargs ***** dt: Internal timestep. scipy.integrate.odeint is forced to calculate values at this interval. For a stiff model a small dt is required for successful simulation. rtol: relative error tolerance. For a stiff model a small relative error tolerance is required for a successful simulation. atol: absolute error tolerance. For a stiff model a small absolute error tolerance is required for a successful simulation. """ #array for the data that the user wants solutions_out=numpy.zeros([len(timepoints), len(InitValues)]) current_concentrations = tuple(InitValues) #current_concentrations,parameters=func.rules(current_concentrations, parameters, timepoints[0]) current_concentrations,parameters=func.rules(current_concentrations, parameters,0) solutions_out[0]=current_concentrations counter = 0 # 1 flag = True #intTime1 = timepoints[0] intTime1 = 0 while flag: intTime2 = min(intTime1+dt, timepoints[counter]) data = odeint(func.modelfunction, current_concentrations, [intTime1, intTime2], args=(parameters,), atol=atol, rtol=rtol ) data[1],parameters = func.rules(data[1],parameters, intTime2) if ((timepoints[counter] - intTime2)<0.000000001): solutions_out[counter] = data[1] counter = counter+1 if counter == len(timepoints): flag = False current_concentrations = data[1] intTime1 = intTime2 return solutions_out
v0_3 = [-0.93240737, -0.86473146] v0_2 = [-v0_3[0] / 2.0, -v0_3[1] / 2.0] v0_1 = [-v0_3[0] / 2.0, -v0_3[1] / 2.0] # vecteur conditions initiales du système différentiel CI = [pos0_1[0],v0_1[0],pos0_1[1],v0_1[1],\ pos0_2[0],v0_2[0],pos0_2[1],v0_2[1],\ pos0_3[0],v0_3[0],pos0_3[1],v0_3[1]] # définition du vecteur temps tmin = 0 tmax = nbp * periode nbpas = (tmax - tmin) / dt t = linspace(tmin, tmax, nbpas) # résolution du système différentiel Y = odeint(TroisCorps, CI, t) # contruction des vecteurs position pour affichage x1 = Y[:, 0] y1 = Y[:, 2] x2 = Y[:, 4] y2 = Y[:, 6] x3 = Y[:, 8] y3 = Y[:, 10] # affichage des résultats fig = figure() plot(x1, y1, 'b', x2, y2, 'g', x3, y3, 'r') show()
newfolder = os.path.join(newfolder, str(previous + 1)) os.makedirs(newfolder) # Define time span t_final = params_dict["t_final"] dt = params_dict["dt"] t = np.linspace(0, t_final, int(t_final / dt)) # Define initial condition vector y0 = (params_dict["V_0"], params_dict["Na_i_0"], params_dict["K_i_0"], params_dict["Ca_i_0"], params_dict["H_i_0"], params_dict["Cl_i_0"], params_dict["a_ur_0"], params_dict["i_ur_0"], params_dict["vol_i_0"], params_dict["cal_0"]) # Call the ODE solver solution_ode = odeint(functions.rhs, y0, t, args=(params_dict, )) # CaLL Voltage Clamp VV, current_dict = Voltage_clamp(solution_ode, params_dict) # save ode_solution with open(os.path.join(newfolder, 'ode_solution.pkl'), 'wb') as file: pickle.dump(solution_ode, file) # save current with open(os.path.join(newfolder, 'current.pkl'), 'wb') as file: pickle.dump(current_dict, file) # save parameters as text file with open(os.path.join(newfolder, 'params.txt'), 'w') as par: for key, value in params_dict.items():