Rank: Member Groups: Registered
Joined: 21/11/2023(UTC) Posts: 24 Was thanked: 2 time(s) in 2 post(s)
|
Hi all, I am putting together a quick worksheet to calculate factor of safety against soil liquefaction triggering. As I have been going step-by-step and defining the various variables, I noticed that all the calculations take place more or less instantaneously, whereas the last variable I defined (N1_60cs) seems to take a relatively long time to calculate (approximately 12 seconds on my machine). The worksheet I have so far is attached. Any thoughts as to what is causing this? Thanks in advance! Seismic Site Class & Liquefaction Potential.sm (125kb) downloaded 7 time(s).
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,647 Location: Italy Was thanked: 1329 time(s) in 875 post(s)
|
Hi, select all > optimization > numeric AND EITHER z:z OR z:+line(...) This is because z:line() is a procedure (something like a function, but for variables); it doesn't evaluates in place on definition, hence is completely calculated from scratch every time you need z, z[j], etc.... Using a + between the definition operator and the line() function, you don't have anymore a procedure; using z:z, it evaluates once from that point onwards. Seismic Site Class & Liquefaction Potential_num.sm (125kb) downloaded 7 time(s).Edited by user 20 December 2023 07:23:06(UTC)
| Reason: clarification |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Member Groups: Registered
Joined: 21/11/2023(UTC) Posts: 24 Was thanked: 2 time(s) in 2 post(s)
|
Perfect, that works!
Much appreciated as always!
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,647 Location: Italy Was thanked: 1329 time(s) in 875 post(s)
|
|
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Your last for/loop, as given, takes 32 s isolate the three components a:=eval(a) , b:=eval( ... timing drops 4 s
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,356 Was thanked: 815 time(s) in 516 post(s)
|
Hi. This is another option, without numeric optimizations. You don't need to use line in your calculations. As Davide says, that makes the calculations faster to SMath. Seismic Site Class & Liquefaction Potential.sm (123kb) downloaded 7 time(s).Bes regards. Alvaro.
|
|
|
|
Rank: Member Groups: Registered
Joined: 21/11/2023(UTC) Posts: 24 Was thanked: 2 time(s) in 2 post(s)
|
Thank you, Alvaro! I like having the lines because it makes it clearer as to which parameter I am defining. I just didn't realize it was slowing it down so much (although putting + in front of the lines makes the problem go away - sort of a win-win!). Thanks again. Originally Posted by: Razonar Hi. This is another option, without numeric optimizations. You don't need to use line in your calculations. As Davide says, that makes the calculations faster to SMath. Seismic Site Class & Liquefaction Potential.sm (123kb) downloaded 7 time(s).Bes regards. Alvaro.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/07/2013(UTC) Posts: 1,128 Was thanked: 509 time(s) in 339 post(s)
|
Originally Posted by: Razonar Hi. This is another option, without numeric optimizations. You don't need to use line in your calculations. Another issue is, all calculation can be done under one for() loop. If data matrices is much longer and not 10, this would benefit too. However, the way it is written look much nicer and cleaner.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,356 Was thanked: 815 time(s) in 516 post(s)
|
Originally Posted by: gth802s I like having the lines because it makes it clearer as to which parameter I am defining. Hi. You can eliminate all the for loops using the SMath index vectorization, which work more or less like the same concept in matlab, with cases() for having some visual separation Seismic Site Class & Liquefaction Potential v2.sm (120kb) downloaded 4 time(s).Best regards. Alvaro.
|
|
|
|
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.