Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

ModelWriting public

Views: 70
Kernel: SageMath (stable)
var('l m h t')
(l, m, h, t)
P=1000 k1=.5 k2=.4 k3=.1 F= [P-(k2*m+k3*h),P-(k1*l+k3*h),P-(k1*l+k2*m)] times=(0,10,1) soln=desolve_odeint(F,[0,0],times,[l,m,h])
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-5-3f6f467b1467> in <module>() 5 F= [P-(k2*m+k3*h),P-(k1*l+k3*h),P-(k1*l+k2*m)] 6 times=(Integer(0),Integer(10),Integer(1)) ----> 7 soln=desolve_odeint(F,[Integer(0),Integer(0)],times,[l,m,h]) /ext/sage/sage-8.1/local/lib/python2.7/site-packages/sage/calculus/desolvers.pyc in desolve_odeint(des, ics, times, dvars, ivar, compute_jac, args, rtol, atol, tcrit, h0, hmax, hmin, ixpr, mxstep, mxhnil, mxordn, mxords, printmessg) 1565 sol=odeint(func, ics, times, args=args, Dfun=Dfun, rtol=rtol, atol=atol, 1566 tcrit=tcrit, h0=h0, hmax=hmax, hmin=hmin, ixpr=ixpr, mxstep=mxstep, -> 1567 mxhnil=mxhnil, mxordn=mxordn, mxords=mxords, printmessg=printmessg) 1568 1569 return sol /ext/sage/sage-8.1/local/lib/python2.7/site-packages/scipy/integrate/odepack.pyc in odeint(func, y0, t, args, Dfun, col_deriv, full_output, ml, mu, rtol, atol, tcrit, h0, hmax, hmin, ixpr, mxstep, mxhnil, mxordn, mxords, printmessg) 213 output = _odepack.odeint(func, y0, t, args, Dfun, col_deriv, ml, mu, 214 full_output, rtol, atol, tcrit, h0, hmax, hmin, --> 215 ixpr, mxstep, mxhnil, mxordn, mxords) 216 if output[-1] < 0: 217 warning_msg = _msgs[output[-1]] + " Run with full_output = 1 to get quantitative information." /ext/sage/sage-8.1/local/lib/python2.7/site-packages/sage/calculus/desolvers.pyc in func(y, t) 1549 v = list(y[:]) 1550 v.append(t) -> 1551 return [dec(*v) for dec in desc] 1552 1553 if not compute_jac: /ext/sage/sage-8.1/src/sage/ext/interpreters/wrapper_rdf.pyx in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (build/cythonized/sage/ext/interpreters/wrapper_rdf.c:2111)() 69 70 def __call__(self, *args): ---> 71 if self._n_args != len(args): raise ValueError 72 cdef double* c_args = self._args 73 cdef int i ValueError:

The model dp/dt=rp(1-p/N)-ep represents the population of horses on an island. The parameter p respresent the the orginal starting population of the horses, while the N represents the the max amounnt of horses the enviroment can handle. The r and e are variables that are related to the parameter p.

var('t v y') g = 9.81 k= 0.47 m=1 F = [v,-g-k/m*abs(v)*v] times=srange(0,4,0.1) soln=desolve_odeint(F,[0,20],times,[y,v])
velocity=zip(times,[x[1] for x in soln]) line(velocity,axes_labels=['time','velocity'])
Image in a Jupyter notebook