4
$\begingroup$

Good morning,

I want to find a numerical solution to the following equation using NDSOLVE:

$$ (1)\hspace{1cm}EJ\frac{\partial^4 v}{\partial x^4} +kv+\rho A \frac{\partial^2 v}{\partial t^2} = q \hspace{1cm} \forall x \in [0;L_o] $$

$$ (2)\hspace{1,7cm}EJ\frac{\partial^4 w}{\partial x^4} +\rho A \frac{\partial^2 w}{\partial t^2} = q \hspace{1cm} \forall x \in [L_o;L] $$

$$ BC_{(1)}:\hspace{1cm} \left|\frac{\partial^3 w}{\partial x^3}\right|_{x=0} =0\hspace{1cm}\left|\frac{\partial^2 w}{\partial x^2}\right|_{x=0} =0\hspace{1cm} \forall t $$

$$ BC_{(2)}:\hspace{1cm} \left|\frac{\partial^3 v}{\partial x^3}\right|_{x=L} =0\hspace{1cm}\left|\frac{\partial^2 v}{\partial x^2}\right|_{x=L} =0\hspace{1cm} \forall t $$

$$ BC_{(1\space and\space2)}:\hspace{1cm} \left|\frac{\partial^i v}{\partial x^i}\right|_{x=L_o} = \left|\frac{\partial^i w}{\partial x^i}\right|_{x=L_o} \hspace{1cm} i=0,...,3 \hspace{0,9cm}\forall t $$

$$IC_{(1\space and\space2)}:\hspace{1cm} v(x,t)=w(x,t)=0\hspace{1cm}\forall x, \space t=0$$

$$\hspace{3,1cm} \frac{\partial v}{\partial t}=\frac{\partial w}{\partial t}=0\hspace{1cm}\forall x, \space t=0 $$

How can I use 'NDSOLVE' and imposing two-domain integration? As suggested let's think that Eq. (2) is valid in y domain so: $$ (2')\hspace{1,7cm}EJ\frac{\partial^4 w}{\partial y^4} +\rho A \frac{\partial^2 w}{\partial t^2} = q \hspace{1cm} \forall y \in [L_o;L] $$ And (as suggested in a comment) let's assume $$ y=y(x),\hspace{1,7cm} y=L-\frac{x}{L_o}(L-L_o)$$ if it's the case we have: $$ \frac{\partial w}{\partial x} =\frac{\partial w}{\partial y}\frac{\mathrm{d}y}{\mathrm{d}x} \hspace{0,2cm}\rightarrow \hspace{0,2cm} \frac{\partial^2 w}{\partial x^2}=\frac{\partial^2 w}{\partial y^2}\Big(\frac{\mathrm{d}y}{\mathrm{d}x}\Big)^2 \hspace{0,2cm} \rightarrow \space...\space\rightarrow \hspace{0,2cm} \frac{\partial^4 w}{\partial y^4}=\frac{\partial^4 w}{\partial x^4}\Big(\frac{\mathrm{d}y}{\mathrm{d}x}\Big)^{-4} \hspace{0,2cm} $$ At the end EQ(2) is replaced with: $$ (2'')\hspace{1,7cm}EJ\Big(\frac{L_o}{L_o-L}\Big)^4\frac{\partial^4 w}{\partial x^4} +\rho A \frac{\partial^2 w}{\partial t^2} = q \hspace{1cm} \forall x \in [0;L_o] $$ I wrote this code but is not working.

Clear[b, h, Emod, m, Lo, Lf, q, k, J, y, u, v];
b = 0.20; (*m*)
h = 0.20; (*m*)
Emod =10000000000;(*modulo el N/m^2*)
Lo = 2;(*l ini m*)
L = 4;(*l fin m*)
rho = 10;(*rho kN/m^3*)
m = b*h*rho;(*N/m*)
q = 1000;(*N/m*)
k = 50000;(*N*)
P = 0.00000; 
J = (b*h^3)/12;
tmax = 30;
sol = NDSolve[{
     (*1st*)
+Emod*J*D[u[t, x], {x, 4}] + k*u[t, x] == q - m*(D[u[t, x], {t, 2}]),
     (*2nd*)
+Emod*J*(Lo/(Lo - L))^4*D[v[t, x], {x, 4}] + k*v[t, x] == q - m*(D[v[t, x],{t, 2}]),

(*1st boundary conditions*)
Derivative[0, 2][u][t, 0] == 0,
Derivative[0, 3][u][t, 0] == P*2/Pi*ArcTan[t],
(*1st initial conditions*)
u[0, x] == 0,
Derivative[1, 0][u][0, x] == 0,

(*2nd boundary conditions*)
(Lo/(Lo - L))^2*Derivative[0, 2][v][t, 0] == 0,
(Lo/(Lo - L))^3*Derivative[0, 3][v][t, 0] == 0,
(*2nd initial conditions*)
v[0, x] == 0,
Derivative[1, 0][v][0, x] == 0,

(*commonn*)
u[t, Lo] == -v[t, Lo],
Derivative[0, 1][u][t, Lo] == (Lo/(Lo - L))*
Derivative[0, 1][v][t, Lo],
Derivative[0, 2][u][t, Lo] == (Lo/(Lo - L))*
Derivative[0, 2][v][t, Lo],
Derivative[0, 3][u][t, Lo] == (Lo/(Lo - L))*
Derivative[0, 3][v][t, Lo]
}, {u, v}, {t, 0, tmax}, {x, 0, Lo}, PrecisionGoal -> 2] 

ADDITIONAL INTERESTING QUESTION: As suggested in a comment I used "UnitStep" function, but now I want to add an ODE that prescribes the "lenght of UniStep". What I want to do is easy understandable by the following code (but it doesn't work):

Lo = 1; L = 3; J = 1; m = 100; Emod = 1; k = 0.5; q = 0.001; tmax = 20;
sol = NDSolve[{
m*D[u1[t, x], {t, 2}] + Emod*J*D[u1[t, x], {x, 4}] + 
UnitStep[Lo + u2[t] - x] k*u1[t, x] == q,
Derivative[0, 2][u1][t, 0] == 0,
Derivative[0, 3][u1][t, 0] == 0,
Derivative[0, 2][u1][t, L] == 0,
Derivative[0, 3][u1][t, L] == 0,
u1[0, x] == -0.001*x,
Derivative[1, 0][u1][0, x] == 0,
D[u2[t], {t,1}] == -NeumannValue[D[u1[t, x], {t, 1}], x == Lo + u2[t]]/
 NeumannValue[D[u1[t, x], {x, 1}], x == Lo + u2[t]],
u2[0] == 0},
{u1, u2}, {t, 0, tmax}, {x, 0, L}, MaxSteps -> 100000]
Plot3D[Evaluate[u1[t, x] /. sol[[1, 1]]], {t, 0, tmax}, {x, 0, L}]
$\endgroup$
7
  • $\begingroup$ Hi, welcome to the site. Your code is different on the $u'''(0)$ term to that which you have written in the LaTeX. Do you have a value for Lo is, or is that an unknown you need to solve for? This looks sort of like a linear eigenvalue equation, except for the terms in q. I can help if so provided q=0. $\endgroup$
    – SPPearce
    Commented Jun 4, 2018 at 10:44
  • $\begingroup$ I think there is a way to do this by redefining the second domain to lie on top of the first, i.e. solving for both $v$ and $w$ in $0<x<L_0$, having rescaled the $x$ in the second equation something like $\hat{x} = (L - x)/(L-L_0)$ (haven't checked that is correct). $\endgroup$
    – SPPearce
    Commented Jun 4, 2018 at 11:03
  • $\begingroup$ Thank you. You are right, both equations (1) and (2) are eigenvalue equations. I was thinking to the same change of variables but I'm little warried about the expression for the derivatives with respect to the equation (2). About the boundary conditions I need in total 8 integration constants. So I've 8 equations as you can see. Of course for x=Lo I need to express the Boundary Conditions as a continuity conditions since I do not know the value of the derivatives evaluated at x=Lo. $\endgroup$
    – Carlo
    Commented Jun 4, 2018 at 13:31
  • $\begingroup$ Sorry! Now I understand what you mean... I'm going to correct BC1 and BC2. I need to solve it for q different from 0. For this reason I'm using NDSOLVE $\endgroup$
    – Carlo
    Commented Jun 4, 2018 at 13:51
  • $\begingroup$ Thank you! I found my fault and I updated the question. $\endgroup$
    – Carlo
    Commented Jun 4, 2018 at 18:48

1 Answer 1

5
$\begingroup$

As the equations are almost the same in the two domains, and all your conditions at the interface are just continuity, you can easily just combine into one equation by using UnitStep to only include the $k$ term in the $v$ region. Here for $L=3$:

Lo = 1;
L = 3;
J = 1;
m = 1;
Emod = 1;
k = 0.5;
q = 0.001;
tmax = 100;
sol = NDSolve[{m*D[u[t, x], {t, 2}] + Emod*J*D[u[t, x], {x, 4}] + 
     UnitStep[Lo - x] k*u[t, x] == q, Derivative[0, 2][u][t, 0] == 0, 
   Derivative[0, 3][u][t, 0] == 0, Derivative[0, 2][u][t, L] == 0, 
   Derivative[0, 3][u][t, L] == 0, u[0, x] == 0, 
   Derivative[1, 0][u][0, x] == 0}, u, {t, 0, tmax}, {x, 0, L}, 
  MaxSteps -> 100000]

Plot3D[Evaluate[u[t, x] /. sol[[1, 1]]], {t, 0, tmax}, {x, 0, L}]

enter image description here

$\endgroup$
5
  • $\begingroup$ Thank you for your suggestion. But I think that if we fix my code it mean that we found a way to use NDSOLVE for a problem with two or more domains connected each other and in witch we are integrating different equations, or different physical processes. May be some other users can help us. $\endgroup$
    – Carlo
    Commented Jun 4, 2018 at 15:42
  • $\begingroup$ I don't think there is a reason why you couldn't just use UnitStep to change the equations entirely. $\endgroup$
    – SPPearce
    Commented Jun 4, 2018 at 15:59
  • $\begingroup$ For me it'works but I was thinking about that to improve our knowledge on NDSOLVE $\endgroup$
    – Carlo
    Commented Jun 4, 2018 at 17:19
  • $\begingroup$ does this trick also work for analytic solutions? $\endgroup$
    – ions me
    Commented Dec 27, 2020 at 20:17
  • $\begingroup$ @IonSme, you can use various piecewise functions (such as UnitStep or HeavisideTheta) inside DSolve`, so you can try it. $\endgroup$
    – SPPearce
    Commented Dec 27, 2020 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.