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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Odesolve "This value must be a function" error

AD_10780197
7-Bedrock

Odesolve "This value must be a function" error

Good evening, everyone.

 

I was working on a model in Mathcad today. Unfortunately, I keep getting an error message every time. To prevent errors, I have removed all units. I have double-checked the function, but I can't seem to find the error. The error message I'm getting is "This value must be a function." I would say that this might be in the theta1(t), z2(t), and theta2(t).

 

I have already reviewed the steps below:

  1. Check the ODEs: Make sure that the ODEs you are trying to solve are properly defined as functions of the independent variable (usually time) and dependent variables. For example, if you have an ODE like dy/dt = f(t, y), make sure that f(t, y) is a valid function.

  2. Correct Function Format: Ensure that the functions used in your ODEs are defined correctly. Mathcad Prime requires well-defined functions with proper syntax. Double-check your function definitions, including parameter lists and mathematical expressions.

  3. Function Inputs: Confirm that you are passing the correct arguments to the Odesolve function. The first argument should be a vector of ODEs, the second argument should be the list of dependent variables, and the third argument should be the initial conditions.

  4. Units and Dimensions: Verify that the units and dimensions of your equations are consistent. In Mathcad Prime, inconsistencies in units can cause errors. Ensure that all units match up correctly.

I think I've probably made a small mistake, but I can't find it

 

Thank you in advance for your help, and I appreciate your assistance. 

 

1 ACCEPTED SOLUTION

Accepted Solutions

I can't contribute anything technically to the task, so just two final comments on the last plot and why it can't work in Prime:

1) You defined the solve block which amongst others also defines the function x.1 tu run from 0 to t.end=2:

Werner_E_0-1700074264528.png

This means that the argument of the function x.1 can only be a value in the interval from 0 to 2. You can't expect any meaningful result if you feed an argument greater than 2

Werner_E_1-1700074380282.png

The first trace in the last plot you tried to create used a range tau.1 = 0, 5 .. 315 and tried to plot x.1(tau.1). But x.1 is only defined for the first value (0) in that range, the next one (5) does not return a value as shown above. This means that this first trace would consist of just one point at position 0. I changed the color of the trace to red and a large "line" width so you can see that point:

Werner_E_2-1700074658259.png

 

2) The second trace in that very same last plot has the range tau.1 at the abscissa and f(x.1) at the ordinate.

You defined the function f using x.1 as formal argument. This might not be the best idea because the name x.1 is already used for a function defined by the solve block, but its not a mistake/error and it works without problems and as expected and you sure can plot that function without any difficulties, here with an actual argument named ttt in a quickplot (= plotting without defining a specific range for ttt)

Werner_E_3-1700074845856.png

But in the plot you created you have still tau.1 at the x-axis and use x.1 as actual argument when you place f(x.1) at the y-axis.
But x.1 is the function defined by your solve block and not a variable. With this combination (unused variable tau.1 and function x.1 as argument of function f), Prime can't possibly know what exactly it's supposed to plot (and I wouldn't know either) 😉

It would be possible to create a plot if you write f(x.1(tau.1)), but here again you would run into the same problem as already explained for the first trace - the plot would only consist of one single point.

 

I wish you all the best for your health and every success in completing your task.

View solution in original post

23 REPLIES 23

Solved

 

It worked, super happy, of course, being a Mathcad novice .The error was in the notation of inertia. Learn from this how to troubleshoot as well.

Can this topic remain open? I want to model the backlash of the gears. I'm trying to do in Mathcad what I used to do in MATLAB. Anyway, thanks to those who reviewed it

ttokoro
20-Turquoise
(To:AD_10780197)

Theta1' doesn't start from 0. ???  So still it has some error.

 

image.pngimage.png


@ttokoro wrote:

Theta1' doesn't start from 0. ???  So still it has some error.

 


No, no error - just numerical inaccuracies.

Adjust the end value (75 -> 0.5) and you may also increase the number of intervals from default 10^3 to something larger:

Werner_E_0-1697639333146.png

I guess the 75 originally were meant to be milliseconds.

Here without a log-scaled abscissa:

Werner_E_0-1697646894878.png

 

 

ttokoro
20-Turquoise
(To:ttokoro)

As Werner says, Odesolve depends on number of points during the time period and also TOL of the calculation.

image.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.png

Thank you for the feedback. I have filled the model with realistic values. As you can see now, the function starts at zero, and the force applied results in a pinion angle rotation equal on both sides. I am still working on addressing the backlash and actively seeking more information on that. I find it quite challenging, but I will continue working on it. To accomplish this, I need to convert the two rotations into a translation and add a specific mechanical hysteresis. Of course, there are three states where the gears have clockwise contact, no contact (in which all damping and stiffness coefficients should be eliminated), and counter-clockwise contact. I am curious to see if I can achieve this in Mathcad.

ttokoro
20-Turquoise
(To:AD_10780197)

You shoud increase the number of ode such as 75, 10^6 or dereat the calculation period such as 0.5 from 75.

Your plot is from 0 to 0.5, 

Also change the TOL from 10^-3 to 10^-7, you can get more good results.

I change 5cos(4t) to sin or 40t or 50... I can get corresponding results by above modifications.

 

image.pngimage.pngimage.pngimage.png

Thank you once again for the correction.

 

I have continued with the model, but I've run into the following issue. I have now added IF functions for the backlash, but I'm still getting an error message. I have reviewed all the variables, but I believe the issue may be with the IF function, though I can't seem to figure it out. I have a feeling that I may have overlooked something. I've included the reference for the calculation in the attachment. Does anyone have the knowledge to give me a nudge in the right direction? I've searched YouTube for an example, but it's hard to find. I'm not sure if I can post this under the same topic. I hope it's okay; otherwise, please let me know. Thank you in advance for your help and effort.

Function definitions should be outside and in front of a solve block.

 

The block is failing because you often used function names without the argument. E.g. x.1' instead of x1'(t).

And if you put a function inside another one, you also must provide the function argument t, so you have to write f(x.1(t)) and not simply f(x.1).

Once you fix these, the odesolveblock works OK.

In the first plot you use theta1.1 but you assigned the result of the solve block to theta.1, so of course theta1.1 is flagged as unknown. Same for index 2.

In the second plot you uses x at the abscissa, but f(x.1) at the ordinate - you have to use f(x) instead.

 

Actually both functions theta look like the are the very same:

Werner_E_0-1698160017525.png

Prime 9 file attached

 

Dear Werner_E

 

Thank you for the fast and prompt response. I will review it this evening. I wasn't aware that these functions needed to be placed outside the solve block, which, in hindsight, seems logical. May I inquire if it's possible to convert your file from Prime 9 to 5? This would help me identify my mistakes.

 

With kind regards,

 

Unfortunately I can't save the file as or convert it to a lower version format - thanks PTC!

Maybe the screenshot can be of help:

Werner_E_0-1698166019540.png

 

LucMeekes
23-Emerald III
(To:AD_10780197)

Here is Werner's file in Prime 5.

 

Success!
Luc

Thank you, Werner and Luc.

 

Your comment, "Actually both functions theta look like they are the very same," was due to a minor typo with the radii. Normally, based on the gear ratio, you should also see the difference reflected in displacement and velocity. Defining the time domains is a much neater approach, which I've also implemented. I've also addressed the remaining comments from your screenshot. Thanks for this!

 

Luc, thanks for the conversion.

 

I'll continue because I expect the angular velocity to reach a steady state at a constant speed eventually.

Not sure what you intended with the last (failing) plot. You defined tau.1 as a (linear) function of t, so you can't use it as a simple variable on the abscissa.

Maybe you were looking for something like this?

Werner_E_0-1698244713462.png

 

Goodmorning Werner_E

 

Sorry for the late response, I was quite ill for a week. Thank you again for your reply. I was looking for the solution below from tttokoro. I just need to figure out how to do it.

 

With kind regards,

 

ttokoro
20-Turquoise
(To:AD_10780197)

image.pngimage.pngimage.pngimage.pngimage.png

image.png

Good morning Ttokoro. Thank you for your response, and I apologize for my delayed reply; I was unwell. I just need to figure out how you did this. I heard from Werner_E that you cannot directly use the result of a function as a variable in another function.

 

With kind regards,

ttokoro
20-Turquoise
(To:AD_10780197)

Oct 25, 2023 01:47 AM. Werner_E shows tend≡2s.(Global Definition Operator.) You can change it 300, 30, 3, 0.003 etc.. And you get the plots I show above.
Plot x axis's max value should change from number to tend and it works.

It's more the Tau function that I'm stuck on. I will continue to try to resolve it. Thanks again for your help.

You should start answering the question what you intend to show when you try to plot x1(tau1) over tau1!!

You defined tau1 as a linear function in t! So what are you trying to do?

ttokoro seems to have redefined tau1 as a simple variable running from 0 to 300.

But when t is running from 0 to 10 (as you defined that range), then tau1(t) runs from 0 to 351344.675 and you can only feed values up to 30 into your function x1.

So again, what are you trying to achieve??

ttokoro
20-Turquoise
(To:AD_10780197)

As Werner_E also says, if you want to plot tend untill 300, 

image.png

Define tau1 such as

image.pngimage.png

Or define tau1 and you get the plot.

image.png

Even you define tau1 untill 315 odesolve solve untill 300 and plot is end at 300.

image.png

Your definition of tau1 is not really respecting the definition of the original function tau1(t).

The plot show the very same as x1(t).

 

One way to use the function tau1 is

Werner_E_0-1698714862700.png

Note the different x-axis scaling.

 

Another way could be

Werner_E_1-1698714923213.png

The reason why only one point at zero  is plotted is because the second value in tau1(t) is already larger than 300 and x1() is not defined for arguments larger than 300.

 

But I would say that finally we should wait what @AD_10780197  says what he intended to achieve with that plot at the end of his sheet.

 

Dear Weaner_E

 

Sorry for the delayed response; things haven't been going smoothly with my health. Hence, the late reply. What I wanted is to modulate the backlash, similar to the document. I extracted these formulas from a paper I shared. It mentions that one can modulate the dead zone.

 

With the formulas I wanted to applied was to goal to plot the  backlash as a characteristic function. I wanted to add first the dimensionless function x ( tau) and later i want to add the discontinuous function. See the plot as example in the shared Mathcad sheet i also snipped the text in the paper. I will continue to try to solve this.

 

Once again, my apologies; currently, I have enough time for Mathcad, but I would have preferred a different manner."

I can't contribute anything technically to the task, so just two final comments on the last plot and why it can't work in Prime:

1) You defined the solve block which amongst others also defines the function x.1 tu run from 0 to t.end=2:

Werner_E_0-1700074264528.png

This means that the argument of the function x.1 can only be a value in the interval from 0 to 2. You can't expect any meaningful result if you feed an argument greater than 2

Werner_E_1-1700074380282.png

The first trace in the last plot you tried to create used a range tau.1 = 0, 5 .. 315 and tried to plot x.1(tau.1). But x.1 is only defined for the first value (0) in that range, the next one (5) does not return a value as shown above. This means that this first trace would consist of just one point at position 0. I changed the color of the trace to red and a large "line" width so you can see that point:

Werner_E_2-1700074658259.png

 

2) The second trace in that very same last plot has the range tau.1 at the abscissa and f(x.1) at the ordinate.

You defined the function f using x.1 as formal argument. This might not be the best idea because the name x.1 is already used for a function defined by the solve block, but its not a mistake/error and it works without problems and as expected and you sure can plot that function without any difficulties, here with an actual argument named ttt in a quickplot (= plotting without defining a specific range for ttt)

Werner_E_3-1700074845856.png

But in the plot you created you have still tau.1 at the x-axis and use x.1 as actual argument when you place f(x.1) at the y-axis.
But x.1 is the function defined by your solve block and not a variable. With this combination (unused variable tau.1 and function x.1 as argument of function f), Prime can't possibly know what exactly it's supposed to plot (and I wouldn't know either) 😉

It would be possible to create a plot if you write f(x.1(tau.1)), but here again you would run into the same problem as already explained for the first trace - the plot would only consist of one single point.

 

I wish you all the best for your health and every success in completing your task.

Top Tags