Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solving a system of differential equations issue 2

Status
Not open for further replies.

mattkoos

Mechanical
Aug 23, 2013
7
I'm trying to solve a system of 2nd order ODEs that have a similar form to the following situation. Two masses are connected by a spring with spring constant f. m1 is the connected to a spring with spring constant h that is connected to a wall. I'm trying to numerically solve for position as a function of time for these two masses m0 and m1.

Here is the link to the sheet demonstrating the issue:


Thank you very much anyone that can help me with this. I'm rather new to MathCad and have been banging my head against the wall over this issue for a little while now.
 
Replies continue below

Recommended for you

I don't know what you're trying to do, but you have a number of syntax errors


TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Okay, now I have a new problem. With the actual problem I'm trying to solve, there are terms that involve velocity in my equation. y2=y0' for example. y2 is a velocity, but Mathcad is treating that term as if it has units of length. Thoughts?
 
can you post a sheet?

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
One problem, I think, is that you use "x" in two different contexts. While you are getting results in the graphs that aren't red, the results are not valid. Your x is defined in context with a 4-element vector (2 0 0 0), not a range from 0-in to 120-in, which I've defined as xx[i

The second problem is in the way the derivative works. Since you defined a function that contains a derivative, you cannot pass a vector to the function and expect it to work correctly, since it would attempt to do the derivative against a vector. You must pass individual values to the function. Therefore, for those graphs that involve the functions with derivatives, you can have xx[i in place of x for both the function and x-axis. I think it would also work using Mathcad's vectorization operator, but this way seems to work OK.


TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Check this out
I used state space instead of differential equations though

here is an example of using rkfixed to solve the problem but there are two masses connected by one spring.

Between the two you should get a good idea of what you need to do.



Peter Nachtwey
Delta Computer Systems
 
Sorry, I think I was unclear. My issue is with the differential equation to the right of the graphs. The one with 'y' as the variable. I have looked at these two comments and also the comments of a friend of mine. It seems that Mathcad15 cannot handle units in the differential equation. I've removed the units in this new sheet and now I'm getting a new error. PNachtwey, this is similar to the second link you gave me. Any suggestions? And thank you both for looking at this. Much appreciated.

 
 http://files.engineering.com/getfile.aspx?folder=476f25f6-ea1a-4a2b-87ff-22595fc80945&file=unitless_differential_equation.xmcd
I found the problem. I substituted 0 for each of the four lines in the D equation until the problem went away. The problem is with the 3rd line. I deleted parts of the third line until the problem went away. The problem was with the (ci+co)/2. If I factored out the (ci+co)/2 so it was multiplied by (1+sign(y2-y3)) it worked.



Peter Nachtwey
Delta Computer Systems
 
Thanks for the debugging tip; that's tricky! Unfortunately the term can't be factored out because one term is the sum over 2 and the other is the difference over 2. Still, I reproduced what you said, and then started messing with that 1 (the 1+sign(blah)). If that number is anything other than 1, it doesn't spit out a solution, so I think it is a limitation in the method. I switched to use Rkadapt instead and it has a solution without changing the equation. And more importantly, one that makes sense, the other one had some pretty big exponents. 10 to the 100 is a liiittle suspect. Thanks for your help!
 
Differential equation integrators like RK and others don't like step jumps or discontinuities. Both the sign and the absolute value function attracted my attention.

Do you know you can use if statements in the system of differential equations? You could try checking the value of the sign() function and then using one of the 3 different formulas depending on the value of sign(). That means you have 3 different versions of the formula in the 3rd row.



Peter Nachtwey
Delta Computer Systems
 
It seems to be working okay with the Rkadapt function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor