cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Pulse function

SOLVED

Re: Pulse function

In my previous post I misspoke. It is a function of velocity, and of the sign of the velocity. So if velocity is positive (increasing), it is one range of values, and if velocity is negative (decreasing), it is a different range of values.


If I cannot do that, then can I set it so that if the v(t) - w(t) is increasing (in other words if the shock is being compressed) it is one constant value, and if v(t) - w(t) is decreasing (shock is being extended) , then it is a different value.

 

Thanks,

Mike

Re: Pulse function

You may make c2(t) a third function of your solve block if you can formulate an equation how c2 is dependent on v.

 

Another way (not sure if thats applicable) could be to make the solve block a function of c2, so you can solve it for different values of c2.

But you can't decide which value c2 should have after you calculated v(t) as the calculation of v(t) uses the value of c2.

So you either

.) use a constant value throughout the solve block

.) or you define c2 as a function of t

.) or you set up c2 as an unknown function of t, provide an equation showing the relationship between c2 and v and use odesolve to solve for v, w and c2.

 

Re: Pulse function

here is an attempt to do what I think you are looking for. You sure have to change the function c2(v) to your needs.

 

Re: Pulse function

Werner,

 

Is there a way to have c2(t) be one of 2 values, as follows:

 

If v(t) - w(t) > v(t-delta t) - w(t-delta t) then c2(t) = 412.7

Otherwise c2(t) = 1615

 

 

Thanks,
Mike

Re: Pulse function

Sure,

use the 'if' function: if( <condition> , <value if true> , value if false> )

In your case:

 

LM_20191127_Condition.png

 

Success!
Luc

Re: Pulse function

Luc,

 

When I put that in the previously posted worksheet, the v(t) turns red and tells me it is undefined.

Re: Pulse function

You would have to provide a value for delta_t.

I am not sure if the numeric algorithm used in the odesolve-block will be able to handle a function with that discontinuity, jumping all of a sudden from 400 to 1600.

You may give it a try and if it does not work you may try using a function with a steep slope instead.

Furthermore ... how should Mathcad know v(t-delta_t) at the start, when t=0 ??

Maybe you can try to formulate the condition differently. In a previous post you said the trigger would be just the sign of v(t).

Maybe you can use v'(t) > w'(t) to achieve what you are looking for? See below

B.png

MC sheet in version 11 attached (for Luc to be able to join in 🙂

Re: Pulse function

I am stumped with the attached sheet. It tells me I have too many initial conditions. If I delete one then it tells me I have too few. I have the feeling that is not the real issue, but I do not know what is. I don't feel like the help files are much help on odesolve. Can someone help out on this one?

Re: Pulse function

You sure messed up badly with the parenthesis - check them in the first and third equation!! The outer one in the third equation is unnecessary and they sure are quite wrong (and a closing one missing) in the first one.

After you correct this you have to add a fifth initial condition, something like v1(0)=???

Furthermore you have to switch the sides in your third equation as Mathcad prefers the derivatives at the LHS.

 

To speed up the calculation you should pre-calculate the first derivative of y(t), otherwise its calculated from anew for every iteration step. You may let the symbolic do the job by writing y1(t):=d/dt y(t) -> (symbolic evaluation) or you do the derivation yourself and define y1(t):= as the appropriate sum. Then use y1(t) instead of d/dt y(t).

But in your case y(t) should be a rectangular signal, so the derivation is zero anyway! (Apart from some single Dirac's. So you may replace d/dty(t) by zero.

Is there any reason why you are using that time consuming and inexact Fourier series instead of the pulse function which Luc provided? In your first post you showed a function where the duty cycle starts at t=0 and now you use another one where it starts at t=0.025. It would be easy to change Lucs function to do the same!

 

I did some changes (see picture below) but the first equation sure should read differently as with the function I came up with we get very high values at the end of the interval (10^13) which probably is not as expected.

 

BTW, your range definitions for t still are wrong!!

The first one (note the red dots) because the dots (..) are interpreted as unknown variable and the second one because you still use the unit s.

B.png

 

Announcements