from sympy import *
t=symbols('t',real=True)
x=Function('x')(t)
dx=x.diff(t)
d2x=x.diff(t,2)
w0,a,F1,F2,w1,w2,p=var(r'\omega_0^2 \alpha F_1 F_2 \omega_1 \omega_2 \phi ')
eqA=Eq(d2x,-(w0*x+a*x**2)+F1*cos(w1*t)+F2*cos(w2*t+p))
display(eqA)
π2ππ‘2π₯(π‘)=πΉ1cos(π1π‘)+πΉ2cos(π2π‘+π)βπΌπ₯2βπ20π₯
s1=dsolve(eqA)
display(s1)
π₯(π‘)=πΆ1+πΆ2π‘βπΉ1cos(π1π‘)π21βπΉ2cos(π2π‘+π)π22+π‘2π₯(βπΌπ₯βπ20)2
M=eqA.subs({F1:0.1,F2:0.06,w0:1,a:0.05,w1:0.8,w2:0.9,p:0})
display(M)
π2ππ‘2π₯(π‘)=β0.05π₯2βπ₯+0.1cos(0.8π‘)+0.06cos(0.9π‘)
s2=dsolve(M, ics={x.subs(t,0): 0.1, x.diff(t).subs(t,0):0})
display(s2)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last) Input In [63], in <cell line:
1>() ----> 1 s2=dsolve(M, ics={x.subs(t,0): 0.1, x.diff(t).subs(t,0):0}) 2
display(s2) File
D:\Programs\Python\Anaconda\lib\site-packages\sympy\solvers\ode\ode.py:605,
in dsolve(eq, func, hint, simplify, ics, xi, eta, x0, n, **kwargs) 602
given_hint = hint # hint given by the user 604 # See the docstring of
_desolve for more details. --> 605 hints = _desolve(eq, func=func, 606
hint=hint,
simplify=True, xi=xi, eta=eta, type='ode', ics=ics, 607 x0=x0, n=n, **kwargs)
608 eq = hints.pop('eq', eq) 609 all_ = hints.pop('all', False) File
D:\Programs\Python\Anaconda\lib\site-packages\sympy\solvers\deutils.py:209,
in _desolve(eq, func, hint, ics, simplify, prep, **kwargs) 205 # Magic that
should only be used internally. Prevents classify_ode from 206 # being
called more than it needs to be by passing its results through 207 #
recursive calls. 208 if kwargs.get('classify', True): --> 209 hints =
classifier(eq, func, dict=True, ics=ics, xi=xi, eta=eta, 210 n=terms, x0=x0,
hint=hint, prep=prep) 212 else: 213 # Here is what all this means: 214 #
(...) 223 # hint. 224 # order: The order of the DE, as determined by
ode_order(). 225 hints = kwargs.get('hint', 226 {'default': hint, 227 hint:
kwargs['match'], 228 'order': kwargs['order']}) File
D:\Programs\Python\Anaconda\lib\site-packages\sympy\solvers\ode\ode.py:1016,
in classify_ode(eq, func, dict, ics, prep, xi, eta, n, **kwargs) 1013 raise
ValueError("Invalid boundary conditions for Function") 1015 else: -> 1016
raise ValueError("Enter boundary conditions of the form ics={f(point):
value, f(x).diff(x, order).subs(x, point): value}") 1018 ode =
SingleODEProblem(eq_orig, func, x, prep=prep, xi=xi, eta=eta) 1019
user_hint = kwargs.get('hint', 'default') ValueError: Enter boundary
conditions of the form ics={f(point): value, f(x).diff(x, order).subs(x,
point): value}
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/e71952fc-30d8-453b-975f-bffe8007f4a5n%40googlegroups.com.