×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Solving a system of differential equations issue2

## Solving a system of differential equations issue

(OP)
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:

http://files.engineering.com/getfile.aspx?folder=8...

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.

### RE: Solving a system of differential equations issue

(OP)
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?

(OP)

### RE: Solving a system of differential equations issue

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.

http://files.engineering.com/getfile.aspx?folder=8...

TTFN
FAQ731-376: Eng-Tips.com Forum Policies

Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers

### RE: Solving a system of differential equations issue

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
http://www.deltamotion.com

### RE: Solving a system of differential equations issue

(OP)
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.

### RE: Solving a system of differential equations issue

Peter Nachtwey
Delta Computer Systems
http://www.deltamotion.com

### RE: Solving a system of differential equations issue

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
http://www.deltamotion.com

### RE: Solving a system of differential equations issue

(OP)
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!

### RE: Solving a system of differential equations issue

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
http://www.deltamotion.com

### RE: Solving a system of differential equations issue

(OP)
It seems to be working okay with the Rkadapt function.

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

#### Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a partâ€™s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!