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

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline Macclad  
#1 Posted : 26 September 2012 23:26:07(UTC)
Macclad

Rank: Newbie

Groups: Registered
Joined: 26/09/2012(UTC)
Posts: 9
Man
United Kingdom
Location: Manchester

Hi All

Hopefully a simple problem for someone clever to sort out.I have used mathcad for a while and I am now teaching Smath to my students on structural engineering courses at University. I have programmed a mathcad sheet which successfully solves any joint loaded pin-jointed framework using the stiffness method. However not all my students want to purchase mathcad and Smath is the obvious (and excellent) alternative. But I am still trying to get my head around some of the syntax issues.

So I am trying to sort out a similar stiffness procedure on Smath, and everything was fine until I reach the transformation matrices. Hopefully if I have attached the files correctly there should be a pdf of the mathcad sheet which shows how I have constructed the transformation matrices (sect 2.4). I have also attached my smath file which has reached this point then failedConfusion

For the frame I have used, there should be 5 transformation matrices - smath only outputs the last one (I was expecting 't' to be a column matrix of 2x8 matrices). There are two for loops, it appears the inner 'z' loop is ok but the outer 'j' loop isnt registering anything before the last number in the range. I am guessing my syntax is arwy, but I hope it is clear what I am trying to achieve?

Any help would be gratefully received - in the meantime I'll try to come at it from a different approach.

Cheers!

Laurence


File Attachment(s):
stiffness.sm (23kb) downloaded 47 time(s).
Mathcad - 2D-Stiffness-Axia-NOTES.pdf (43kb) downloaded 60 time(s).

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

Offline mkraska  
#2 Posted : 27 September 2012 18:09:33(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,988
Germany

Was thanked: 1127 time(s) in 723 post(s)
Hi Laurence

I made something similar for my FEA classes. It could be done much simpler, but the target was to demonstrate how the global system is assembled and reduced based on constraints.
I found the det function unreliable. Thus I was not able to demonstrate the singularity of the unconstrained system and the regularity of the reduced one. You need to apply scaling which need to be adjusted to a very narrow range where the det function will work at all.

The sheet is in german but the code should be self documenting.

Best regards, Martin Kraska
File Attachment(s):
Fachwerk UE2.sm (77kb) downloaded 50 time(s).
Fachwerk HA1.sm (71kb) downloaded 40 time(s).
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline Ioan  
#3 Posted : 27 September 2012 23:25:17(UTC)
Ioan


Rank: Member

Groups: Registered
Joined: 17/06/2012(UTC)
Posts: 26
France, Metropolitan

Was thanked: 1 time(s) in 1 post(s)
Hi Laurence,


Here attached is another way to solve your problem.
Hoping to be useful and hoping that my way is enough readable.
I do not use the penalty method for supports; equations are written only for the active DOFs.


Best regards,


Ioan
File Attachment(s):
artic3dr.sm (73kb) downloaded 56 time(s).
Offline Macclad  
#4 Posted : 28 September 2012 00:37:42(UTC)
Macclad

Rank: Newbie

Groups: Registered
Joined: 26/09/2012(UTC)
Posts: 9
Man
United Kingdom
Location: Manchester

Hi Martin and Ioan

Very many thanks for your replies, the sheets are very informative and given me some great ideas for solving this - I can see how you have used the 'for' loops to achieve the transformations. (Also the graphics are a very useful addition, that's the next thing for me to implement now!).

From the teaching perspective, I tend to teach the hand calcs with reduced DOF's but wanted to show the students the logistics of programming the method in a general way, i.e keep all DOF's to show the singular global matrix then how to apply boundaries to the system to remove the singularity. Anyway, still not sure why my for loops don't work, but I won't lose too much sleep, I'll use your methods.

Thanks once again!

Laurence
Offline Macclad  
#5 Posted : 30 September 2012 01:43:15(UTC)
Macclad

Rank: Newbie

Groups: Registered
Joined: 26/09/2012(UTC)
Posts: 9
Man
United Kingdom
Location: Manchester

Hi again, new problme this time

So I have my transfrmation matrices sorted now, gone through the process of inverting the matrix, multiplying by the load vector to work out displacements. But now I have encountered a different problem, one which might be a bug?

Hopefully the attached sheet will explain my problem. When I evaluate (K^-1)*(P), the displacements are evaluated as expected - correct answer. However when I let a variable equal this, then evaluate the variable the answers are wrong.

So I have been playing with the numbers in the matrix and it appears that when I put all the small exponential numbers to zero then the variable assignment works. But why should the direct evaluation work and not the variable assignment in the first place. It strikes me that something in the maths during variable assignment is intrinsically different. I can understand how very small or large numbers could affect the calculations, but why does it work for one and not the other. Im quite confused now.

Any ideas? Is this an smath bug or am I doing something stupid?

Many thanks

Laurence

File Attachment(s):
Check.pdf (43kb) downloaded 37 time(s).
Check.sm (24kb) downloaded 27 time(s).
Offline mkraska  
#6 Posted : 30 September 2012 02:53:31(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,988
Germany

Was thanked: 1127 time(s) in 723 post(s)
Hi Laurence

evaluation of expressions is one of the biggest mysteries of SMath. I have never seen (or better: understood) a consistent description of what the interaction of numeric and symbolic evaluation is meant to work.

In your case the assignment to the variable disp delays the evaluation to the point where disp is going to be displayed. Immediate evaluation of KG^{-1}*P works but delayed does not (Why?). You can enforce immediate evaluation upon assignment to disp by using the function eval():

disp:eval(KG^{-1}*P)

results in

disp=mat(0.183,-0.527,-0.078,-0.41,1*10^{-16},-3.91*10^{-17},-1*10^{-16},-6.09*10^{-17},8,1)

(mm unit refused to be displayed in the post preview, therefore I removed it from the result)

Equally well you can generate the precision problem by switching to symbolic optimization in the immediate evaluation of KG^{-1}*P. You get something ugly like:

KG^{-1}*P=mat(-154029677706911/1227751447183550,371846259893873/1635302861611220,150994944000000/282161279734733,395987199384982/508161646518145,-1949477283233400/115154739031931000000000000000,71907646210181/9860498487058500000000000000,-1453125/2091995697675820000000,185335047104285/8598781694818370000000000000000,8,1)

Want to know what the decimal representation of this is? Do not hope for just switching back to numeric optimization. Instead copy the result and evaluate that numerically:

mat(-154029677706911/1227751447183550,371846259893873/1635302861611220,150994944000000/282161279734733,395987199384982/508161646518145,-1949477283233400/115154739031931000000000000000,71907646210181/9860498487058500000000000000,-1453125/2091995697675820000000,185335047104285/8598781694818370000000000000000,8,1)=mat(-0.13,0.23,0.54,0.78,-1.69*10^{-14},7.29*10^{-15},-6.95*10^{-16},2.16*10^{-17},8,1)@#

This is the garbage result that you had to face when displaying the variable disp.

Just to emphasize the problem: numeric evaluation of exactly the same expression results in

KG^{-1}*P=mat(0.183,-0.527,-0.078,-0.41,1*10^{-16},-3.91*10^{-17},-1*10^{-16},-6.09*10^{-17},8,1)

Seems like a severe bug in the symbolic engine. This makes me recommend to my students not to use symbolic features at all. However, than you would have to embrace every expression with eval() before assignment. This looks really ugly in otherwise nice smath sheets. Still the general rule seems to apply: The more questionable the results are, the more evals you should spread over your sheet.

Once I made the proposal to introduce different assignment operators for delayed and immediate evaluation, say :<- and := respectively.
Also, symbolic and numeric evaluation (aka "optimization" ) should be visually distinct, say = and -> (as in Mathcad)
You may have noted that many examples and bug reports have expressions with comments like "symbolic" just to indicate what could be visible from a consistent notation. However, this seems to be a matter of taste or not easy to implement.

It seems to me that the default assignment type is symbolic/delayed. How about switching the default to immediate evaluation? Half the traffic in the forum could be saved. Those who want trouble really hard, could perhaps be given a function symb() ;-)

Best regards, Martin Kraska

Edited by user 30 September 2012 03:18:57(UTC)  | Reason: Not specified

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline Ioan  
#7 Posted : 30 September 2012 09:50:57(UTC)
Ioan


Rank: Member

Groups: Registered
Joined: 17/06/2012(UTC)
Posts: 26
France, Metropolitan

Was thanked: 1 time(s) in 1 post(s)
Hi Laurence,


I fully agree Martin's opinions.

For simplifying - if your switch disp expression from symbolical optimisation to numerical optimisation you have the right result (see attached file) with good units also.

I've seen also that often the symbolical optimisation give false numerical results.


Best regards,


Ioan
File Attachment(s):
Check mid.sm (71kb) downloaded 38 time(s).
Offline mkraska  
#8 Posted : 30 September 2012 10:56:06(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,988
Germany

Was thanked: 1127 time(s) in 723 post(s)
Hi Ioan,

thank you for pointing out the straight solution. Indeed this works without using eval. I guess you need eval if such assignments are done within procedure definitions where there is no other way to control optimization on a statement by statement base.

Would be interesting to know Andrey's priority level of this problem. I guess that debugging the symbolic engine is far from being fun. My hope is that there is at least a chance to have the visual markup of symbolic/numeric optimization resolved. Otherwise one cannot trust printed SMath sheets, as Laurence's example again demonstrated. I even would ask for a global preference setting to numeric evaluation.

Best regards, Martin Kraska
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 30/09/2012(UTC)
Offline Macclad  
#9 Posted : 30 September 2012 22:59:26(UTC)
Macclad

Rank: Newbie

Groups: Registered
Joined: 26/09/2012(UTC)
Posts: 9
Man
United Kingdom
Location: Manchester

Hi Ioan and Martin

Many thanks for your impressive replies, its clear to me what is happening now. It seems my days with Mathcad have been charmed, looks like I have quite a lot to learn with Smath still. Great that it works now though!

All the best

Laurence

(PS, been trying to press the 'thank' button on your posts but it's coming back with a web error at the moment - hopefully it will work shortly)

Users browsing this topic
Guest
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.