Best way to solve this non-linear equation?

10 ビュー (過去 30 日間)
HVdB
HVdB 2022 年 11 月 26 日
コメント済み: HVdB 2022 年 11 月 28 日
I have a set of equations I need to solve, the first equation (not the one shown below) is a PDE solved through pdepe(), but for the form of the following equation I am not sure which approach to take to solve it:
I have tried solving it symbolically through solve() and dsolve(), but that did not work, with solve() returning an empty sym and dsolve returning the following:
syms a(t) c(x) d(x)
b = 2*10^(-7);
eqn = diff(a,t) == -b*(diff(c,x)*diff((d/c),x) + rho_a*diff((d/c),2,x));
sol = dsolve(eqn,a);
Error using mupadengine/feval_internal
No differential equations found. Specify differential equations by using symbolic functions.
Error in dsolve>mupadDsolve (line 334)
T = feval_internal(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 203)
sol = mupadDsolve(args, options);
Error in odetest (line 6)
sol = dsolve(eqn,a);

回答 (1 件)

John D'Errico
John D'Errico 2022 年 11 月 26 日
編集済み: John D'Errico 2022 年 11 月 26 日
dsolve is not used to solve a PDE. It applies ONLY to an ODE or a system of ODEs.
help dsolve
DSOLVE Symbolic solution of ordinary differential equations. DSOLVE will not accept equations as strings in a future release. Use symbolic expressions or sym objects instead. For example, use syms y(t); dsolve(diff(y)==y) instead of dsolve('Dy=y'). DSOLVE(eqn1,eqn2, ...) accepts symbolic equations representing ordinary differential equations and initial conditions. By default, the independent variable is 't'. The independent variable may be changed from 't' to some other symbolic variable by including that variable as the last input argument. The DIFF function constructs derivatives of symbolic functions (see sym/symfun). Initial conditions involving derivatives must use an intermediate variable. For example, syms x(t) Dx = diff(x); dsolve(diff(Dx) == -x, Dx(0) == 1) If the number of initial conditions given is less than the number of dependent variables, the resulting solutions will obtain arbitrary constants, C1, C2, etc. Three different types of output are possible. For one equation and one output, the resulting solution is returned, with multiple solutions to a nonlinear equation in a symbolic vector. For several equations and an equal number of outputs, the results are sorted in lexicographic order and assigned to the outputs. For several equations and a single output, a structure containing the solutions is returned. If no closed-form (explicit) solution is found, then a warning is given and the empty sym is returned. DSOLVE(...,'IgnoreAnalyticConstraints',VAL) controls the level of mathematical rigor to use on the analytical constraints of the solution (branch cuts, division by zero, etc). The options for VAL are TRUE or FALSE. Specify FALSE to use the highest level of mathematical rigor in finding any solutions. The default is TRUE. DSOLVE(...,'MaxDegree',n) controls the maximum degree of polynomials for which explicit formulas will be used in SOLVE calls during the computation. n must be a positive integer smaller than 5. The default is 2. DSOLVE(...,'Implicit',true) returns the solution as a vector of equations, relating the dependent and the independent variable. This option is not allowed for systems of differential equations. DSOLVE(...,'ExpansionPoint',a) returns the solution as a series around the expansion point a. DSOLVE(...,'Order',n) returns the solution as a series with order n-1. Examples: % Example 1 syms x(t) a dsolve(diff(x) == -a*x) returns ans = C1/exp(a*t) % Example 2: changing the independent variable x = dsolve(diff(x) == -a*x, x(0) == 1, 's') returns x = 1/exp(a*s) syms x(s) a x = dsolve(diff(x) == -a*x, x(0) == 1) returns x = 1/exp(a*s) % Example 3: solving systems of ODEs syms f(t) g(t) S = dsolve(diff(f) == f + g, diff(g) == -f + g,f(0) == 1,g(0) == 2) returns a structure S with fields S.f = (i + 1/2)/exp(t*(i - 1)) - exp(t*(i + 1))*(i - 1/2) S.g = exp(t*(i + 1))*(i/2 + 1) - (i/2 - 1)/exp(t*(i - 1)) syms f(t) g(t) v = [f;g]; A = [1 1; -1 1]; S = dsolve(diff(v) == A*v, v(0) == [1;2]) returns a structure S with fields S.f = exp(t)*cos(t) + 2*exp(t)*sin(t) S.g = 2*exp(t)*cos(t) - exp(t)*sin(t) % Example 3: using options syms y(t) dsolve(sqrt(diff(y))==y) returns ans = 0 syms y(t) dsolve(sqrt(diff(y))==y, 'IgnoreAnalyticConstraints', false) warns Warning: The solutions are subject to the following conditions: (C67 + t)*(1/(C67 + t)^2)^(1/2) = -1 and returns ans = -1/(C67 + t) % Example 4: Higher order systems syms y(t) a Dy = diff(y); D2y = diff(y,2); dsolve(D2y == -a^2*y, y(0) == 1, Dy(pi/a) == 0) syms w(t) Dw = diff(w); D2w = diff(w,2); w = dsolve(diff(D2w) == -w, w(0)==1, Dw(0)==0, D2w(0)==0) See also SOLVE, SUBS, SYM/DIFF, odeToVectorfield. Documentation for dsolve doc dsolve
There are no symbolic solvers in MATLAB that apply to a PDE. Sorry. In SOME (moderately rare, and usually pretty simple) cases, an analytical solution can be found. For example, sometimes, separation of variables can be used to derive a solution.
As it is though, you ask for the best way to solve the PDE. That would be by the use of PDEPE (which you claim to have already done) or similar tools. Or you could write your own code, using a variety of methods for the numerical solution of a PDE.
  5 件のコメント
HVdB
HVdB 2022 年 11 月 28 日
Thank you! That sounds like a good approach!

サインインしてコメントする。

カテゴリ

Find more on Partial Differential Equation Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by