Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


2 Pages12>
Options
Go to last post Go to first unread
Offline Alex M.  
#1 Posted : 15 April 2018 09:23:52(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Good day SMath community,

I was battling this issue in my worksheet for a better part of the weekend.

I wrote a formula (biaxial bending in a column) to calculate unknown input loads based on known response. A key to practical use of the formula is to solve for unknown response based on known input loads (backwards of what formula does). I attempted to use FindRoot() with no success.

I decided to write a simple "solver" using a for() loop, which i have done many other times before. To my surprise the custom formula does not evaluate correctly inside the for() loop, while evaulating just fine outside it.

This is rather baffling. Please take a look and help - i honestly dont know what to do here - this should be a simple task which proved to be very stubborn.

Many thanks!

formula.sm (89kb) downloaded 23 time(s).formula.png

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Davide Carpi  
#2 Posted : 15 April 2018 12:04:10(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,639
Man
Italy
Location: Italy

Was thanked: 1323 time(s) in 873 post(s)
Hello Alex,

Originally Posted by: Alex M. Go to Quoted Post
I decided to write a simple "solver" using a for() loop, which i have done many other times before. To my surprise the custom formula does not evaluate correctly inside the for() loop, while evaulating just fine outside it.

The loop fails on i=2, where the neutral axis has a value that doesn't cross the section; looking at biaxial(2) this case is not handled (local variable #chunk not defined -> error on stress block properties calculation -> error in the loop)


Originally Posted by: Alex M. Go to Quoted Post
definition of xii "erased"

This is by design since SMath Studio 0.99.6622

Originally Posted by: Andrey Ivashov Go to Quoted Post
Calculation error happened during definition of the variable/function clears previous value of this variable/function if it is available;

Edited by user 15 April 2018 12:08:42(UTC)  | Reason: Not specified

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 15/04/2018(UTC)
Offline Jean Giraud  
#3 Posted : 15 April 2018 16:39:33(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Alex M. Go to Quoted Post
This is rather baffling. Please take a look and help - i honestly dont know what to do here - this should be a simple task which proved to be very stubborn.

Alex, everything is OK and NOT in few points.

I worked a bit on your previous version. Now the last error "_ not defined"
The incompatibility is too deep to be isolated... % appears as a factor is
no problem for FindRoot solver. rotation° is the problem in the solver.
The function is OK in the program data*rot(,), but the solver does not solve
for (°Wink because the demand is for solving the argument of a function of a function..
This in Mathcad is possible via an iterative Given/Find, not directly possible in Smath.

What you can do and in fact is what you need, create a matrix of solutions from
... biaxial(°,%) ... works fine in the attached 6179

Cheers Alex ... Jean

formula[1].sm (109kb) downloaded 28 time(s).

thanks 1 user thanked Jean Giraud for this useful post.
on 15/04/2018(UTC)
Offline Alex M.  
#4 Posted : 15 April 2018 18:38:32(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Oh thank you very much Davide and Jean, now i have something to work with :-)

Jean, i entertained initially the idea of creating a matrix of solutions, but what proved to be a challenge is to interpolate the desired one from said matrix (which is a 3D surface)

Davide, so is "variable undefined" a sign that function evaluated to an error?

I managed to get my solution using a for() loop by removing the error you mentioned, but once i encapsulate said for loop in a function call the error is back

formulaR2.sm (100kb) downloaded 24 time(s).

Edited by user 15 April 2018 19:43:47(UTC)  | Reason: Not specified

Offline Jean Giraud  
#5 Posted : 15 April 2018 20:19:12(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Alex M. Go to Quoted Post
Oh thank you very much Davide and Jean, noiw i have something to work with :-)

Jean, i entertained initially the idea of creating a matrix of solutions, but what proved to be a challenge is to interpolate the desire one from said matrix (which is a 3D surface)


Alex,
Your "self entertaining" was correct, but unfortunately up to this point,
you have a system, not a surface. Mathcad would plot nothing either.
Most probably it would generate "a critical error occured".

The last olive can be programmed for convenience.
I love projects that understand nothing but work !
I'm not a bridge maker, just a Process Control old man.

Cheers Alex ... Jean

formula[2].sm (129kb) downloaded 23 time(s).


Offline Jean Giraud  
#6 Posted : 15 April 2018 23:22:42(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
... Alex,

From this completed demo, you can:
interpolate [cinterp from sanity plots]
I tried some surface interpolation,
too small data set [4 x 3].

Jean

formula[3].sm (124kb) downloaded 27 time(s).
thanks 1 user thanked Jean Giraud for this useful post.
on 16/04/2018(UTC)
Offline Alex M.  
#7 Posted : 16 April 2018 00:36:16(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
... Alex,

From this completed demo, you can:
interpolate [cinterp from sanity plots]
I tried some surface interpolation,
too small data set [4 x 3].

Jean

formula[3].sm (124kb) downloaded 27 time(s).



Hi Jean, greatly appreciate your help. In the example you developed, can you interpolate unknown values of "°" & "%" based on given values of P.z and ratio Mx/My? or find all possible values Mx and My for a known value of Pz This is what i am after. Surface defined by dots in coordinate system (PzMxMy) is an interaction diagram of column failure

Edited by user 16 April 2018 00:41:07(UTC)  | Reason: Not specified

Offline Alex M.  
#8 Posted : 16 April 2018 02:26:07(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
I have attempted to approach the task from a different angle - parametrically define Pz(a#,na#) Mx(a#,na#) My(a#,na#)

and solve for a# and na# by evaluating Pz, Mx, My using function at().

Function at() does not work with my definition.

Davide, why am i hitting a brick wall here?

Thanks BiaxialColumnCheck.sm (557kb) downloaded 30 time(s).
Offline Jean Giraud  
#9 Posted : 16 April 2018 02:57:25(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Hi Jean,
1. In the example you developed, can you interpolate
unknown values of "°" & "%" based on given values of Pz and ratio Mx/My?
2. or find all possible values Mx and My for a known value of Pz.
This is what I am after.
3. Surface defined by dots in coordinate system (PzMxMy)
is an interaction diagram of column failure
================================================

1. done, perfect
2. Don't understand completely
3. up until now, does not work well [NFG !]
Offline Jean Giraud  
#10 Posted : 16 April 2018 04:25:17(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post

1. done, perfect
2. Don't understand completely
3. up until now, does not work well [NFG !]

================================
1 & 3 done

Can you re-explain your # 2

Alex3D.sm (37kb) downloaded 29 time(s).
formula[3] Copy.sm (155kb) downloaded 25 time(s).

The 3D crashes the main sheet
Offline Jean Giraud  
#11 Posted : 16 April 2018 04:33:19(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
2. or find all possible values Mx and My for a known value of Pz.
This is what I am after.
=====================================

I think it's possible
Offline Alex M.  
#12 Posted : 16 April 2018 04:40:35(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Originally Posted by: Jean Giraud Go to Quoted Post

1. done, perfect
2. Don't understand completely
3. up until now, does not work well [NFG !]

================================
1 & 3 done

Can you re-explain your # 2

Alex3D.sm (37kb) downloaded 29 time(s).
formula[3] Copy.sm (155kb) downloaded 25 time(s).

The 3D crashes the main sheet


Hi Jean, huge effort here from you - BIG thanks. Will take some time for me to digest. To make it a little easier for me can you point out where i can "interpolate unknown values of "°" & "%" based on given values of Pz and ratio Mx/My?". I know Pz, ratio of Mx/Mz and need to find "°" & "%" that correspond to it (all data is spit out by biaxial() formula).

Many Thanks!
Offline Jean Giraud  
#13 Posted : 16 April 2018 05:29:52(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Alex M. Go to Quoted Post
Hi Jean, huge effort here from you - BIG thanks. Will take some time for me to digest. To make it a little easier for me can you point out where i can "interpolate unknown values of "°"

====== will be back on that tomorrow ======

Here is the lookup wrt PzMxMy, alternately search from either col.

formula[3] Copy.sm (169kb) downloaded 20 time(s).
Offline Jean Giraud  
#14 Posted : 16 April 2018 07:01:37(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Alex M. Go to Quoted Post
To make it a little easier for me can you point out where
I can "interpolate unknown values of "°"

Maybe, I didn't completely understood ?
Here is the refreshed version.

formula[3] Copy.sm (163kb) downloaded 21 time(s).

Offline Davide Carpi  
#15 Posted : 16 April 2018 10:32:52(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,639
Man
Italy
Location: Italy

Was thanked: 1323 time(s) in 873 post(s)
Originally Posted by: Alex M. Go to Quoted Post
I managed to get my solution using a for() loop by removing the error you mentioned, but once i encapsulate said for loop in a function call the error is back


The problem here is that when you pass to a function an argument that requires numerical evalution and the evaluation is not possible because undefined variables, the preprocessing fails (at smath level)

the workaround is to create a function that internally defines the leftside as the function that cannot be passed in argument and call your solver internally

notice eval@ inside the solver, this makes possible to use solveNR both directly (with at()) both within the wrapper function solvePcr (not sure now why at() doesn't work in both the cases, have to investigate when it will be possible)


formulaR2_rev2.sm (106kb) downloaded 35 time(s).

Edited by user 16 April 2018 11:07:57(UTC)  | Reason: Not specified

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 16/04/2018(UTC)
Offline Jean Giraud  
#16 Posted : 16 April 2018 16:57:04(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Davide, Alex ... thanks for the distiller-solution.

Two points about your Newton-Raphson example:

1. Will it work for this application in traditional code ?
2. Two [2] pitfalls:
2\a. about your cubic, it is ill-posed. In maths, it is paramount
polynomials are expressed in Lagrange canonical format.
For quick getting the polyroots and set the cubic solver.
In fact, cubic may have complex roots [your example is cubic complex].
Complex solutions are essentials in modeling/solving Control Systems.

2\b. The Smath native "roots" solves directly your example.

Rev(2) most appreciated for eventual hard solving future.

rootsAccurate.PNG
Newton-Raphson.PNG

Solve roots Newton-Raphson.sm (52kb) downloaded 25 time(s).
thanks 1 user thanked Jean Giraud for this useful post.
on 17/04/2018(UTC)
Offline Alex M.  
#17 Posted : 17 April 2018 19:21:34(UTC)
Alex M.


Rank: Advanced Member

Groups: Registered
Joined: 03/03/2014(UTC)
Posts: 418
Canada

Was thanked: 125 time(s) in 96 post(s)
investigated a few options:

1. point interpolation on a surface is tough to implement (for me)
2. Solving for na# works well (Davide's last post)
3. Solving for rotation does not work well (relationship is far from linear, solver chokes up too often - see example formulaR4.sm (221kb) downloaded 15 time(s). )

My current solution is solve for na# (Davide's last post) by bracketing the rotation till desired Mx/My is achieved (not shown here)
Offline Jean Giraud  
#18 Posted : 17 April 2018 20:40:12(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Alex M. Go to Quoted Post
investigated a few options:

1. point interpolation on a surface is tough to implement (for me)
2. Solving for na# works well (Davide's last post)
3. Solving for rotation does not work well (relationship is far from linear, solver chokes up too often - see example <a class="attachedImageLink {html:false,image:false,video:false}" href="/forum/resource.ashx?a=22839


From your suggested NR solver, here is attached.
It solves 'na' [height%] wrt target Pz, rot°
From what I understand, you would like solving mutually [rot°, height%].
That, you have it from the 'test function'
... you can collect multiple zigzag test ?
Between close enough two points test, safe to linterp(,,,)
For sparse > two test, just cinterp(,,,)
Surface from another post is strictly linear. The Spline2D is equivalent
to quadratic interpolation, but meshed fine enough is immaterial.

Next => visit your last attachment.

Project_0 Biaxial SolveRotdeg.sm (106kb) downloaded 27 time(s).

Offline Jean Giraud  
#19 Posted : 18 April 2018 00:34:16(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
... suite,

by solving, simultaneously [rot°, _%], if biaxial would be an analytical f(x,y)
you can solve x<=y or vice versa y<=x. Up until now, found only one that Smath/Maple
does not solve. On the other hand, biaxial(rot°, _%) generates 3 sets of results.
The CreateMesh [not the Smath CreateMesh] can alternately scan/evaluate and tabulate
results for further use ... I'm working on that, in the mean time, if you have a good
range of each [rot°, _%] that would be nice, though easy to modify.
Offline Jean Giraud  
#20 Posted : 18 April 2018 06:31:56(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
... suite as far as manageable.
I got lost in your last attempt !
Cheers Alex

Project_0 Biaxial SolveRotdeg.sm (141kb) downloaded 36 time(s).
Users browsing this topic
2 Pages12>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.