Convergence analysis

I’m trying to make a convergence analysis of the mesh in a shell model.

I have made the following sample code in which I would like to change the parameter #meshsize and the print the results to a table.

+prog aqua urs:19.1 $ Materials
    conc 1 c 40 ec 17500
    end
+prog sofimshc urs:19.2 $ Geometry
    SYST 2DSN GDIV 200000 GDIR NEGY
    CTRL Mesh 1 ; CTRL HMIN #meshsize
    UNIT 6
    SPT 1 0 0        ; SPT 2 10000 0 ; SPT 3 10000 10000 ; SPT 4 0 10000
    SLN 1 1 2 fix pp ; SLN 2 2 3     ; SLN 3 3 4         ; SLN 4 4 1
    SAR 1 MNO 1 t 100
        SARB TYPE OUT NL 1,2,3,4
    end
+prog TALPA urs:19.3 $ Analysis
    ccrl opt solv val 4
    ECHO CSPL NO
    CS 1 TITL 'Meshsize = #meshsize'
        CGRP ALL ACT IN
end
+APPLY $(name)_csg.dat
+PROG RESULTS urs:19.6 $ Table results
    XLSX NAME "Mesh#Meshsize.xlsx" WS "Worksheet"
    LC   NO 1
        TXTP SHOW SIGN OVLP AMAX
        NODE TYPE   UX REPR DLST
END

Ideally I would put it all inside a loop but like this:

let#mesh 100,1000,2500,5000
loop#i 4
    let#meshsize #mesh(#i)
    <MY CODE GOES HERE>
endloop

but the loop of course won’t run without a +prog to run inside, and I can’t run my other programs if I wrap it in eg. a +prog template, so that is not possible either.

Is there a clever way around this?

Kind regards
Martin

Use iter (chapter 11.7 in the manual):

First a “definition” template:
+Prog Template
Sto#i 0, 5 $ Start at 0 and do 5 iterations
Sto#i_mesh 0.9, 0.7, 0.5 $ mesh size factor
End

Then your program modules with iter (iter 99 means iterate up tp 99 times):
+Prog sofimshc iter 99
Let#meshsize #i_mesh(#i) $ Using the current mesh size
… insert your code (iter 99 with all prorgrams)

Then you end it with a control template:
+Prog template iter 99
If (#i(0)<#i(1)) $ as long as iteration isn’t done
Sto#i #i+1
Else $ Quit iteration once you have done enough of them
Exit_iteration
Endif
End

I’m not sure if it works with apply though.
If it doesn’t, i would:

  • Prepare your entire file in teddy (not ssd)
  • Define mesh size as a parameter (chapter 11.2), i.e. you use $(mesh_size) as your variable
  • Write a bat script that loops over mesh sizes, defining it as environmental variables (Set mesh_size in bat)
  • Then call sps.exe with the teddy file in the bat script (sps is the calculation window, but bat version)

Perfect, the bat approach works like a charm!

Final setup looks like this:

loop.bat:

@echo off
set list=100 500 2000 5000

FOR %%i in (%list%) DO (
set mesh_size=%%i
"C:\Program Files\SOFiSTiK\2020\SOFiSTiK 2020\sps.exe" "%UserProfile%\OneDrive\SOFiSTiK\Convergence_analysis\file.dat"
)

file.dat:

+prog aqua urs:19.1 $ Materials
    NORM DC EN 1992-2004 G 9.8
    conc 1 c 40 ec 17500
END
+prog sofimshc urs:19.2 $ Geometry
    SYST 2DSN GDIV 200000 GDIR NEGY
    CTRL Mesh 1 ; CTRL HMIN $(mesh_size)
    UNIT 6
    SPT 1 0 0        ; SPT 2 10000 0 ; SPT 3 10000 10000 ; SPT 4 0 10000
    SLN 1 1 2 fix pp ; SLN 2 2 3     ; SLN 3 3 4         ; SLN 4 4 1
    SAR 1 MNO 1 t 100
        SARB TYPE OUT NL 1,2,3,4
END
+prog TALPA urs:19.3 $ Analysis
    ccrl opt solv val 4
    ECHO CSPL NO
    CS 1 TITL 'Meshsize = $(mesh_size)'
        CGRP ALL ACT IN
END
+APPLY $(name)_csg.dat
+PROG RESULTS urs:19.6 $ Table results
    XLSX NAME "Mesh$(mesh_size).xlsx" WS "Worksheet"
    LC   NO 1
        TXTP SHOW SIGN OVLP AMAX
        NODE TYPE   UX REPR DLST