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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

How to automate extrapolation in mathcad and write the result to excel?

ptc-5640736
1-Newbie

How to automate extrapolation in mathcad and write the result to excel?

Hi..

The Excel calculation given below in each step needs to check the current and stroke and import the force value from mathcad.

The Force thus obtained will give the current for the second step, which along with the corresponding stroke value again the force has to be taken from mathcad.

Is it posiible to automate this process using Mathcad by reading the excelsheet?

Capture.PNG

I have attached my worksheets herewith.

29 REPLIES 29
MikeArmstrong
5-Regular Member
(To:ptc-5640736)

Use the READEXCEL function to bring in your data. I take it you are manually bringing it in at the moment?

Yes. The highlighted Force values were entered manually by checking in mathcad.

MikeArmstrong
5-Regular Member
(To:ptc-5640736)

To automate, use the READEXCEL feature found on the Input/Output tab and specify the range of data you want to input.

C.jpg

Thank you Mike.

After reading from excel i am getting current and stroke matrix. Now, how to automate and write the result in excel???

Capture.PNG

MikeArmstrong
5-Regular Member
(To:ptc-5640736)

You can remove the submatrix functions as you can select the exact data from the Excel component and assign to variables. Leave the out if range lines and linterp.

The M matrix given is fixed.In excel,please assume that initially only step 1 is there with the given initial conditions.The Force obtained from mathcad extrapolation for a combination of F(0,3.5) is 0. The force thus obtained gives the stroke on second step as highlighted.Now the stroke in second step along with the corresponding Current has to be given to Mathcad as input.i.e F(11.5,3.5) so that the mathcad result should be written in the place of (-3.41) and the same continues in further steps.

is it possible to automate like the same? ( say, the iteration should stop when Stroke value reaches 2mm)

Capture.PNG

MikeArmstrong
5-Regular Member
(To:ptc-5640736)

I think I understand what you are after: You want a function creating in Mathcad say F(x,y) = Force. The arguments x and y are current and stroke, respectively?

Are all the current values less than 276Amp extrapolation?

Exactly..

The Actual extrapolation starts at 289A where my stroke value start reducing. I extrapolated previous values using trend Function in excel.

MikeArmstrong
5-Regular Member
(To:ptc-5640736)

A few things to consider. You could use the predict function within Prime to calculate the current.

If you already have your data, why not use a lookup function for the current and return the Force?

MikeArmstrong
5-Regular Member
(To:ptc-5640736)

How about something like this?

Remember to change the paths of the READEXCEL functions.

Clipboard01.jpg

There may be a reason not to do this; but why can't Mathcad calculate the current (bypass the ECXEL sheet)?

If EXCEL can compute the current from the force, then it should be possible to do that calculation in Mathcad as well.

Fred Kohlhepp wrote:

There may be a reason not to do this; but why can't Mathcad calculate the current (bypass the ECXEL sheet)?

If EXCEL can compute the current from the force, then it should be possible to do that calculation in Mathcad as well.

I agree Fred, but Saranya has used a lot of data contained within Excel to calculate the Current values so I thought it would be best to keep it there.

Thank you..

Kindly go through the description given below:

Capture.PNG

Problem description:

The table in the left side is the actual calculation that I’m doing.

The data in the right side is supporting my calculation.

The left side table values describe the performance of a coil which is fed by current (270,429,600,…) at different strokes(3.5mm,3mm,2.5mm,….) from Ansys simulation.

I need to estimate force value for any combination of current and stroke (say 280A & 3.4mm) which need to be extrapolated from the right side available data.

For that I have used the Mathcad program above which picks force value for any combination of Current and Stroke.

Coming to the Left side excel calculation, Kindly assume that Initially I know only the values highlighted in green.

The force in each step decides the stroke in the next step.

The column highlighted in Yellow ( current and stroke) in each step have to decide what will be the value of force.

Since it is not possible to manually enter the F(current,stroke) values in Mathcad for each step to check what will be the force and write it in the column highlighted in blue in left side table, I m thinking whether this can be automated like iteration process. Either by linking this Mathcad program in excel and make it run each time or reading the excel data in Mathcad and obtaining the required force values to fill the remaining steps in excel.

Saranya T L

MikeArmstrong
5-Regular Member
(To:ptc-5640736)

Thanks for the explanation I think I now understand. Can you confirm how the force dictates the stroke and I think the whole thing can be automated.

Sure Mike…Kindly follow the arrow in the given figure. I think this will make the flow of calculation clear to you.Capture.PNG

Saranya T L

MikeArmstrong
5-Regular Member
(To:ptc-5640736)

Great explanation thanks. I am a little lost I'm afraid. Maybe it's with all the spooky kids knocking at my door .

My question is why do you need to use Excel why you seem to have completed your task in Mathcad.

Thank You..

I have calculated current in mathcad itself.. Now how to do the iteration step by step???

I am stuck on finding force by checking with the stroke and Current step by step...

Capture.PNG

Please find the worksheet attached herewith..

MikeArmstrong
5-Regular Member
(To:ptc-5640736)

You can use a For Loop and iterate through either stroke or gap, whichever the iterative variable is. This will allow you to calculate a, velocity and inturn Stroke.

I will take Stroke as the variable.can i write an expression sometng like S(i) := S(i-1)+ V(i-1)*T directly???

Also For that I need to pick the Force value F(current, stroke) which should be F(i) for further Calculation.(Net force, Acceleration,Velocity...)

Confused..

MikeArmstrong
5-Regular Member
(To:ptc-5640736)

Based on your image above time is the variable. Sorry yet again I am a little confused witgh what you are trying to do.

Maybe it will be best to start again by providing the data you initially have and we'll through it step by step?

Sorry if I have no been much help

I also don't know what kind of calculation you have in mind because your step 1 at the end of the sheet does not show in any way what step 2 is supposed to be and I see no velocity? Whats the meaning of gap_1? You never used that variable.

Do you want to calculate Springforce when Stroke is 0m; 3.5mm, 7mm; 10.5mm; .....?

This would be too easy, I guess, and I don't see where your interpolating function F(c,s) would come into play.

Maybe you consider open a new thread (we are far way from the initial subject now) and explain in more detail what you need.

Maybe also you think too much in Excel terms of cell ranges and iteration steps. A more functional approach could be beneficial but its hard to say without knowing what you really need.

See below the first part of your calculation done without any vectors:

1.png

If you really need the vecors you used for plotting you may calculate them afterwards as well. I did it without using that undocumented feature which you used to turn the range i into a vector. Here i still is a range but T is defined as vector and so is I(T) which ofcourse you may assign to a variable if needed.

2.png

There's a better way to do this.

As Werner began, convert to functions, then solve the differential equation:

Thank You All..

I will try with the method suggested and get back shortly...

Im sorry If im confusing again..

Is it possible to make the no.of iterations as variable??

I have made some modifications...but i guess it is making a circular reference...

I tried to write the expressions for acceleration,velocity and stroke as below...

Capture.PNG

Okay;

You have a problem with your interpolation schemes, and the one in Force_recalculation just does not work.

polynomial regression fit shows how to get a polynomial fit to your data--linterp requires you to span the range of data, and when current or stroke goes outside your table it fails. (Your current will be negative some of the time!)

Force recalculation takes the third order fit of current, stroke, to force and shows the interpolation.

solenoid and spring takes the same interpolation and solves the ode for position.

I'm not sure of the correlation of x with stroke, and what to do about negative currents and forces.

Good luck!

Thank You..

I agree...The problem is I am trying to find at what time 2mm stroke is attained & At that instant what will be the Force and current. The known values are I_t Characteristics, Spring data and inputs for calculation and interpolation.

I have changed the data in table with respect to Stroke so that the gap need not be considered.

In the interpolation function, each time entering the current and stroke value is not possible. Since i have to calculate the same for n number of iterations.(from time 0 till the time at 2 mm stroke)

Also, Im not worried about negative currents because my calculation will converge before the positive peak of current is reached. (2mm stroke is attained in less than 4 milliseconds).

Whoops!

It's apparent from your Force_estimation sheet that you're using a "less than full functioned" Mathcad; it won't accept programming, and it probably won't do differential equation solving either.

The "old" mathcad would allow an iterative solution to be done, but Prime won't accept the structure when I type it in, which is why you can find ITR as a program which (I assume) didn't run for you either.

Going to have to think about this a bit.

You changed the table to reflect stroke; does the spring force increase or decrease as stroke goes from 0 mm to 2 mm?

PS: The lines where I put a fixed time into a function (AC_Factor and Fn) were temporary diagnostics (Making sure the function would evaluate to a reasonable answer.) Further along you can then use the function with a variable time to get the AC factor or the force at that time. (The goal is to solve this problem with time as a variable; two approaches--very small time steps (iteration) or solving the differential equation of motion (A = F/m)

Turns out Prime can do "seeded iteration"

And if I could type the expresseions correctly it would work: Fred Kohlhepp

Thank You so much...

Yes.Most of the programs are not working. I am using Prime 2.

May I know which Mathcad version is suitable for my application?

Also,

In the interpolation function when j=0, I Guess I need Force at (Currentj, Strokej).

Capture.PNG

Top Tags