## 15 Reputation

17 years, 142 days

## solution is 0 because of the piecewise f...

Hello,

I used your method to get the solution for the second derivative, and it works.

Unfortunatley in my particular case the PDE is equated to a piecewise function, which seems to yield 0 for the the second derivative, on the domain on which the piecewise function was defined.

Any suggestions on why this could happen and how I can remedy the that.

Thank you

restart; alias(H = Heaviside);

ibc := {w(0, t) = 0, w(1, t) = 0, w(x, 0) = 0, (D[2](w))(x, 0) = 0, (D[1, 1](w))(0, t) = 0, (D[1, 1](w))(1, t) = 0}; pde4 := {diff(w(x, t), t, t)+v(x, t)+b(x, t) = piecewise(0 <= t and t <= 1, sin(t)*(H(x-0.1e-3-t)-H(x-0.1e-3-t+.1))), diff(w(x, t), t) = v(x, t), diff(w(x, t), `\$`(x, 4)) = b(x, t)};

res4 := evalf(pdsolve(pde4, ibc, time = t, numeric, spacestep = 1/10, timestep = 1/10));

res4:-plot([25*w(x, t), [25*v(x, t), color = blue], [b(x, t), color = green]], x = 1/2, t = 0 .. 45);

res4:-plot(piecewise(0 <= t and t <= 1, sin(t)*(H(x-0.1e-3-t)-H(x-0.1e-3-t+.1)))-v(x, t)-b(x, t), x = 1/2, t = 0 .. 3*Pi);

## solution is 0 because of the piecewise f...

Hello,

I used your method to get the solution for the second derivative, and it works.

Unfortunatley in my particular case the PDE is equated to a piecewise function, which seems to yield 0 for the the second derivative, on the domain on which the piecewise function was defined.

Any suggestions on why this could happen and how I can remedy the that.

Thank you

restart; alias(H = Heaviside);

ibc := {w(0, t) = 0, w(1, t) = 0, w(x, 0) = 0, (D[2](w))(x, 0) = 0, (D[1, 1](w))(0, t) = 0, (D[1, 1](w))(1, t) = 0}; pde4 := {diff(w(x, t), t, t)+v(x, t)+b(x, t) = piecewise(0 <= t and t <= 1, sin(t)*(H(x-0.1e-3-t)-H(x-0.1e-3-t+.1))), diff(w(x, t), t) = v(x, t), diff(w(x, t), `\$`(x, 4)) = b(x, t)};

res4 := evalf(pdsolve(pde4, ibc, time = t, numeric, spacestep = 1/10, timestep = 1/10));

res4:-plot([25*w(x, t), [25*v(x, t), color = blue], [b(x, t), color = green]], x = 1/2, t = 0 .. 45);

res4:-plot(piecewise(0 <= t and t <= 1, sin(t)*(H(x-0.1e-3-t)-H(x-0.1e-3-t+.1)))-v(x, t)-b(x, t), x = 1/2, t = 0 .. 3*Pi);

## Solution yields 0...

Thank you for the elaborate answer, unfortunatley it yields 0 for my particular problem.

## Solution yields 0...

Thank you for the elaborate answer, unfortunatley it yields 0 for my particular problem.

## Thank you...

@Carl Love do you think the second derivative of the solution should have a different formulation than the first derivative?

Do you have any hints on how the solution could converge faster?

Thanks!!

## the attached file...

ptr_mplprims.mw

this is the worksheet that I have been working on, sorry for not uploading it the first time.

## They helped!...

@PatrickT  I looked over them, the examples and explanations there really gave me insights on the events command, as much as I could understand, tough, as my programming skills are very low.

## This helps...

@Preben Alsholm  Thank you,  this is much more efficient than making a sequence for u(t)!

## This helps...

@Preben Alsholm  Thank you,  this is much more efficient than making a sequence for u(t)!

## how to control the sign change...

Thank you,

is it possible to change the sign for each timestep of the event, I was thinking of making a sequence...

eq:=diff(y(t),t,t)+u(t)-y(t)=0);
res:=dsolve({eq,y(0)=0,D(y)(0)=1,u(0)=0},numeric,output=listprocedure,
discrete_variables=[u(t)::float,n(t)::float],
events=[[t=0,u(t)=y(t)+diff(y(t),t)+0.02],[t=5,u(t)=y(t)+diff(y(t),t)-0.02],[t=10,u(t)=y(t)+diff(y(t),t)+0.02],[t=15,u(t)=y(t)+diff(y(t),t)-0.02],[t=[0,1/2]]);
plots:-odeplot(res,[[t,y(t)],[t,u(t)]],0..20);

## how to control the sign change...

Thank you,

is it possible to change the sign for each timestep of the event, I was thinking of making a sequence...

eq:=diff(y(t),t,t)+u(t)-y(t)=0);
res:=dsolve({eq,y(0)=0,D(y)(0)=1,u(0)=0},numeric,output=listprocedure,
discrete_variables=[u(t)::float,n(t)::float],
events=[[t=0,u(t)=y(t)+diff(y(t),t)+0.02],[t=5,u(t)=y(t)+diff(y(t),t)-0.02],[t=10,u(t)=y(t)+diff(y(t),t)+0.02],[t=15,u(t)=y(t)+diff(y(t),t)-0.02],[t=[0,1/2]]);
plots:-odeplot(res,[[t,y(t)],[t,u(t)]],0..20);

## Wow !!!...

thank you a lot, this really speeds things up.

## Wow !!!...

thank you a lot, this really speeds things up.

## All parameters are known, 't' is the var...

@Carl Love g=9.81. Thanks for answering.

 Page 1 of 1
﻿