This : w0 … = var(r'\omega_0^2… is suspect and confusing syntax. Rewriting 
your problem in a more conventional way :
>>> omega_0, alpha, F_1, F_2, omega_1, omega_2, phi = symbols("omega_0, 
alpha, F_1, F_2, omega_1, omega_2, phi") >>> t=symbols("t", real=True) >>> 
x=Function("x") >>> eqA=Eq(diff(x(t), t, 2), 
omega_0**2*x(t)+alpha+F_1*cos(omega_1*t)+F_2*cos(omega_2*t+phi)) 

a solution is immediate :
>>> dsolve(eqA, x(t)) Eq(x(t), C1*exp(-omega_0*t) + C2*exp(omega_0*t) - 
F_1*cos(omega_1*t)/(omega_0**2 + omega_1**2) - F_2*cos(omega_2*t + 
phi)/(omega_0**2 + omega_2**2) - alpha/omega_0**2) 

HTH,
​
Le dimanche 2 avril 2023 à 08:04:11 UTC+2, [email protected] a écrit :

>
> 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/1a0f7070-8b14-429b-a6df-887b761610f4n%40googlegroups.com.

Reply via email to