Раздел «Язык Си».SymPyODE:
Задачник: Филиппова

def apply_ics(sol, ics, x, known_params):
....: """
....: Apply the initial conditions (ics), given as a dictionary on
....: the form ics = {y(0): y0, y(x).diff(x).subs(x, 0): yp0, ...},
....: to the solution of the ODE with independent variable x.
....: The undetermined integration constants C1, C2, ... are extracted
....: from the free symbols of the ODE solution, excluding symbols in
....: the known_params list.
....: """
....: free_params = sol.free_symbols - set(known_params)
....: eqs = [(sol.lhs.diff(x, n) - sol.rhs.diff(x, n)).subs(x, 0).subs(ics)
....:     for n in range(len(ics))]
....: sol_params = sympy.solve(eqs, free_params)
....: return sol.subs(sol_params)

In [22]: ode_sol
In [23]: apply_ics(ode_sol, ics, t, [k, Ta])

IDEA! Чтобы в Input[23] первого примера получить ответ в виде [{C1:T0−Ta}], добавьте функцию solve аргумент dict=True, то есть C_sol = solve(C_eq, dict=True)

Attachment sort Action Size Date Who Comment
ODE_1Temperature.ipynb manage 44.5 K 23 Apr 2017 - 23:20 TatyanaDerbysheva dT/dt = -k(T-Ta), notebook
ODE_1Temperature.py.txt manage 3.9 K 23 Apr 2017 - 23:20 TatyanaDerbysheva dT/dt = -k(T-Ta), python file
ODE_1Temperature.html manage 279.2 K 24 Apr 2017 - 00:35 TatyanaDerbysheva dT/dt = -k(T-Ta), html
ODE_2Garmonic.ipynb manage 57.4 K 24 Apr 2017 - 00:36 TatyanaDerbysheva колебания груза на пружине, находим C1 и C2 отдель
ODE_2Garmonic.py.txt manage 4.2 K 24 Apr 2017 - 00:37 TatyanaDerbysheva колебания груза на пружине, находим C1 и C2 отдель
ODE_2Garmonic-Copy1.ipynb manage 54.7 K 24 Apr 2017 - 00:37 TatyanaDerbysheva колебания груза на пружине, находим C1 и C2 вместе
ODE_2Garmonic-Copy1.py.txt manage 3.5 K 24 Apr 2017 - 00:38 TatyanaDerbysheva колебания груза на пружине, находим C1 и C2 вместе
ODE_2Garmonic-Copy1.html manage 288.0 K 24 Apr 2017 - 00:38 TatyanaDerbysheva колебания груза на пружине, находим C1 и C2 вместе