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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

ODE error

PW_10297783
4-Participant

ODE error

Hello,

I am using Adams to solve the differential equations as below but failed, may anyone could suggest how to solve it or should I use another equation.The error can only disappear when x was deleted in the equation.

.

PW_10297783_1-1705961895174.png,x from 0 to 10000

 

Thanks in advance.

PW

1 ACCEPTED SOLUTION

Accepted Solutions

Your sheet is still missing - its not attached.

I see that you changed the initial value for x significantly now from 0 to 3600!

In Prime you would have to use the commands inside of a solve block!

The syntax for odesolve had changed, too, from legacy Mathcad to Prime (look it up in the help):

Werner_E_1-1706026793157.png

 

The attached file is in Format of Prime 6., so you should be able to open it with P7.

View solution in original post

17 REPLIES 17

You have to write y(x), not just y.

Furthermore I guess you will run into problems because the right hand term is not defined for the start value x=0 (division by zero).

 

I changed the start value to x=10^-10 and it works OK.

Here done in Mathcad 15 using "odesolve" with Adams/BDF chosen as algorithm.
I let x only run up to 1000 - you can see that y approaches zero continually.

Werner_E_0-1705971602764.png

 

For further questions please attach your worksheet, not just a picture. And in case you are using Prime also state which version.

PW_10297783
4-Participant
(To:Werner_E)

Thank you Werner,

Please fine my error enclosed.I am using Prime 7.0.

PW_10297783_0-1706025335242.png

 

Thank for guiding me how to proceed.

PW

Your sheet is still missing - its not attached.

I see that you changed the initial value for x significantly now from 0 to 3600!

In Prime you would have to use the commands inside of a solve block!

The syntax for odesolve had changed, too, from legacy Mathcad to Prime (look it up in the help):

Werner_E_1-1706026793157.png

 

The attached file is in Format of Prime 6., so you should be able to open it with P7.

PW_10297783
4-Participant
(To:Werner_E)

thank you,I drag the sheet one more time,

LucMeekes
23-Emerald III
(To:PW_10297783)

Should be more like in attached.

 

Notice how Prime handles solve blocks different from Mathcad (15 and before).

 

Success!
Luc

PW_10297783
4-Participant
(To:LucMeekes)

Dears,

I come back to this topic further more,How could I make the If program fuction in this Odesolve modle please.I use Prime 9.0 now.

PW_10297783_0-1708194731420.png

 

LucMeekes
23-Emerald III
(To:PW_10297783)

Not sure what you want. Note that in your solve block, y is a function: y(x), described by the ODE, and dependent on c. Now it appears that you want c (that y depends on) to change depending on the value of y....?

I see a chicken<>egg problem.

 

Success!
Luc

I, too, see the chicken and egg problem mentioned by Luc 😉

 

I parametrized your solve block so you can create a solution for any given value of c.

Then I defined the two solution functions for c=1 and c=4 (y1 and y5).

Finally a function y was defined which equals y1 as long as its value is over 0.05 and then drops down to y5.
But I hardly can imagine that this is really what you are looking for ...

Werner_E_1-1708199342553.png

 

Prime 6 file attached

Here is a different approach with a similar result.

I used the if-function but of course you could as well use the program if-statement.

Werner_E_0-1708199735775.png

Still not sure if you are really looking for something like this.

Prime 6 file attached

PW_10297783
4-Participant
(To:Werner_E)

This is exactly what I need,thank you both.

 

Had not seen your second posting with the file and in the meantime edited my answer above and added a file created in P6 (I never bothered to install P7 or P8).

Basically the same as what was posted by Luc - use a solve block and change the syntax of "odesolve".

 

BTW, Prime also allows units in a solve block with "odesolve" (legacy Mathcad didn't), so you should take advantage of Primes unit-awareness and use units, too.

LucMeekes
23-Emerald III
(To:PW_10297783)

The differential equation:

LucMeekes_1-1706006192435.png

 

Has solution:

LucMeekes_6-1706014251553.png

Now with:

LucMeekes_0-1706014384173.png

we know c also.

So:

LucMeekes_1-1706014505825.png

We can compare the numeric solution

LucMeekes_2-1706014601400.png

with the exact solution:

LucMeekes_3-1706014623951.png

The difference is:

LucMeekes_4-1706014656114.png

Success!
Luc

 

Forgot to mention that in case you are using a current version of Prime, the ODE can also be solved symbolically

Werner_E_0-1706021356120.png

It also looks like we could add an initial condition

Werner_E_1-1706021394768.png

But the first attempt using a numeric value failed

Werner_E_2-1706021450242.png

Using 1/10 instead of 0.1 does the trick:

Werner_E_3-1706021551583.png

Werner_E_4-1706021576967.png

Werner_E_0-1706021713525.png

 

Using the prime symbol for the derivative you may even omit the function argument x, but I won't suggest doing so

Werner_E_0-1706021993403.png

 

 

 

 

 

PW_10297783
4-Participant
(To:Werner_E)

May you upload your file for symbolical solution in your free time please,I am not able to proceed with the mistake below

 

PW_10297783_0-1707138184622.png

 

Thanks

LucMeekes
23-Emerald III
(To:PW_10297783)

Prime 7 does not support solving differential equations symbolically. You have to upgrade to Prime 9 for that.

 

Success!

Luc

PW_10297783
4-Participant
(To:LucMeekes)

Thanks for your rapid reply Luc,

Also for your proffessional response for solve block/numeric solution last month.

You don't show the sheet and you don't say what the error message is you get, so we have to guess and either you forgot to clear y (at least for symbolical usage) before you solve symbolically (you can't solve for a variable or function which already is defined)

Werner_E_2-1707150333223.png

or its because you are still using Prime 7.  Version 9 is the first one with the ability to solve ODEs symbolically. That's the reason why I wrote  "Forgot to mention that in case you are using a current version of Prime, the ODE can also be solved symbolically".

 

For whatever its worth I nonetheless attach the P9 sheet with the symbolic solutions.

 

Top Tags