Mathematica Asked on April 20, 2021
I’m having some trouble using DSolve
to solve a partial differential equation.
This is my code:
pde = d*cp*D[T[t, z], t] == k*D[T[t, z], {z, 2}] + Q;
sol =
DSolve[
{pde, T[0, z] == Tamb, (D[T[t, z], z] /. z -> 0) == 0,
(-k*D[T[t, z], z] /. z -> a) == h*(T[t, a] - Tamb)},
T[t, z], {t, z}]
The output is the differential equation, but it’s not evaluated
I’m assuming that there is a mistake in what I wrote because even when I use DSolve
with the partial differential equation that is given as example in the DSolve
article in the Documentation Center, I don’t get a solution.
For example, I dont get a solution from this code either:
pd = D[y[x, t] t] + 2 D[y[, t], x] == 0;
sol1 = DSolve[{pd, y[0, t] == Sin[t]}, y[x, t], {x, t}]
I am using Wolfram Mathematica 7.0.
I tried it using the LaplaceTransform, but I haven't get the final analytical answer. These are my codes:
pde = d*cp*D[T[t, z], t] == k*D[T[t, z], {z, 2}] + Q;
ic = T[0, z] == Tamb;
bc1 = D[T[t, z], z] == 0(*z[Rule]0*);
bc2 = -k*D[T[t, z], z] == h*(T[t, z] - Tamb)(*z->a*);
solbc1 = DSolve[{bc1}, T, {t, z}][[1]]
solc1 = DSolve[{pde /. solbc1, ic /. solbc1}, C[1][t], t][[1, 1]] (*C[1][t] -> (Q t + cp d Tamb)/(cp d)*)
bc1new = T[t, 0] == (Q t + cp d Tamb)/(cp d);
solbc2 = DSolve[{bc2}, T, {t, z}][[1]]
solc1 = DSolve[{pde /. solbc2, ic /. solbc2}, C[1][t], t][[1, 1]]
T[t, z] /. solbc2[[1]] /. solc1 /. z -> a
bc2new = T[t, a] == ((-1 + E^((h^2 t)/(cp d k))) k Q)/h^2 + Tamb;
teqn = Simplify[
LaplaceTransform[{pde, bc1new, bc2new}, t, s] /.
HoldPattern[LaplaceTransform[a_, t, s]] :> a]
tsolmid = FullSimplify[DSolve[teqn, T[t, z], z]][[1, 1, -1]]
The InverseLaplaceTransform seems difficult to get the results for this question...
Answered by helloworldzcp on April 20, 2021
Anohter method:
pde=d*cp*D[T[t,z],t]==k*D[T[t,z],{z,2}]+Q;
ic=T[0,z]==Tamb;
bc1=D[T[t,z],z]==0(*z0*);
bc2=-k*D[T[t,z],z]==h*(T[t,z]-Tamb)(*za*);
solbc1=DSolve[{bc1},T,{t,z}][[1]];
solc1=DSolve[{pde/.solbc1,ic/.solbc1},C[1][t],t][[1,1]]; (*C[1][t](Q t+cp d Tamb)/(cp d)*)
bc1new=T[t,0]==(Q t+cp d Tamb)/(cp d)
solbc2=DSolve[{bc2},T,{t,z}][[1]];
solc1=DSolve[{pde/.solbc2,ic/.solbc2},C[1][t],t][[1,1]] ; (*C[1][t](^((h z)/k) (-1+^((h^2 t)/(cp d k))) k Q)/h^2*)
T[t,z]/.solbc2[[1]]/.solc1/.z->a;
bc2new=T[t,a]==((-1+E^((h^2 t)/(cp d k))) k Q)/h^2+Tamb
(*First let’s deal with the complex boundary condition*)
T[t_,z_]=c[t,z]+(t Q)/(d*cp);
Simplify[pde]
eqnx[z_]=d*cp*D[c[(k*t)/(d*cp*z^2)],t]-k*D[c[(k*t)/(d*cp*z^2)],{z,2}](*x=(k t)/(cp d z^2)*);
eqn'=FullSimplify[eqnx[Sqrt[(k t)/(d*cp*x)]]]==0
solx=DSolve[eqn',c[x],{x}][[1,1]]/.x->(k*t)/(d*cp*z^2);(*c[(k t)/(cp d z^2)]C[2]-2 Sqrt[π] C[1] Erf[1/(2 Sqrt[(k t)/(cp d z^2)])]*)
T[t_,z_]=C[2]-2 Sqrt[π] C[1] Erf[1/(2 Sqrt[(k t)/(cp d z^2)])]+(t Q)/(d*cp);
solc2=Solve[Limit[T[t,z],z->0]==(Q t+cp d Tamb)/(cp d),C[2]][[1,1]] (*use bc1new*)
T[t_,z_]=T[t,z]/.solc2;
solc1=Solve[Limit[T[t,z],z->a]==((-1+E^((h^2 t)/(cp d k))) k Q)/h^2+Tamb,C[1]][[1,1]] (*use bc2new*)
T[t_,z_]=Simplify[T[t,z]/.solc1]
Well, actually I don't know if my result is right.I hope so ^_^
Answered by helloworldzcp on April 20, 2021
Using Mathematica 12.2.0
now can solve.
First example:
pde = d*cp*D[T[t, z], t] == k*D[T[t, z], {z, 2}] + Q;
sol = DSolve[{pde, T[0, z] == Tamb, (D[T[t, z], z] /. z -> 0) ==
0, (-k*D[T[t, z], z] /. z -> a) == h*(T[t, a] - Tamb)},
T[t, z], {t, z}]
(*{
{T[t, z] -> Piecewise[{{Tamb + Inactive[Sum][(2*(1 - E^(-((k*t*K[2, K
[1]])/(cp*d))))*h^2*Q*Cos[z*Sqrt[K[2, K[1]]]]*
Sin[a*Sqrt[K[2, K[1]]]])/(k^3*K[2, K[1]]^(3/2)*Sqrt[-((h*(-((a*h)/k) -
Sin[a*Sqrt[K[2, K[1]]]]^2))/k)]*
Sqrt[(h*(a*h + k*Sin[a*Sqrt[K[2, K[1]]]]^2))/k^2]), {K[1], 1, Infinity}],
h/(k*Sqrt[K[2, K[1]]]) == Tan[a*Sqrt[K[2, K[1]]]] &&
cp*d*k > 0 && h*k > 0 && Element[K[1], Integers] && K[1] >= 1 && K[2, K[1]] > 0}},
Indeterminate]}}*)
Second example:
pd = D[y[x, t] t] + 2 D[y[x, t], x] == 0;
sol1 = DSolve[{pd, y[0, t] == Sin[t]}, y[x, t], {x, t}]
(*{{y[x, t] -> E^(-((t x)/2)) Sin[t]}}*)
Answered by Mariusz Iwaniuk on April 20, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP