Calibrate material parameter

Asked by Mithushan Soundaranathan on 2021-05-24

Hi,

I am calibrating k1 and kp for luding material for a compaction process. I am not sure how to do it. I method I am thinking of is to first run the simulation with initial value, and calculate RMSE with exp values. Then update the parameter, and run simulation until I get the lowest RMSE value. I was wondering how can run the simulation (calibration process) continuously, without pressing run for each new parameter update. Has someone experience in calibrated material parameter, how could help me out.

Best,
Mithu

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

> calculate RMSE with exp values

the key here is to define exp values "well" - which values (peak values? curve shape? some overall trend, like line slope? ...?), how to measure them (not to take "errors" (some peak force due to oscilation), but not missing relevant trends), set proper relation/weights between the values .....

Dimensional analysis can help (search "dimensional analysis calibration") reducing the number of values.

> how can run the simulation (calibration process) continuously, without pressing run

use O.run [1], possibly with O.wait [2], waitIfBatch [3], have a look at manual [4]

For "multiple running", you have several options:
- yade batch mode [5], "manual" trial-and-error optimization of parameters
- create a (python?) program running simulations, evaluate results, updating input parameters ...
- ... (many more options)

Cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.Omega.run
[2] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.Omega.wait
[3] https://yade-dem.org/doc/yade.utils.html#yade.utils.waitIfBatch
[4] https://yade-dem.org/doc/user.html#stop-conditions
[5] https://yade-dem.org/doc/user.html#batch-queuing-and-execution-yade-batch

Revision history for this message
Mithushan Soundaranathan (mithushan93) said :
#2

Hi Jan,

Thanks that helped,

> create a (python?) program running simulations, evaluate results, updating input parameters.
-How can I do that, which command do I need add to run it again with the new parameters?

Best,
Mithu

Revision history for this message
Jan Stránský (honzik) said :
#3

>> create a (python?) program running simulations, evaluate results, updating input parameters.
> -How can I do that, which command do I need add to run it again with the new parameters?

there are maaany options.

1) "external" program
- read original template script, replace input parameters
- run simulation (using .e.g python subprocess module)
- extract saved data
- update input parameters
- repeat

2) using O.reset() inside a loop

.....

a MWE for approach 1:

### simulation.py.in
from yade import plot
radius = {radius}
b = sphere((0,0,0),radius)
O.bodies.append(b)
mass = sum(b.state.mass for b in O.bodies)
plot.addData(mass=mass)
plot.saveDataTxt("m.dat")
###

### runner.py
import subprocess
yade = "yadedaily"
radii = [1,2,3] # input data to simulate

with open("simulation.py.in") as f:
    scriptIn = f.read() # "template"

for r in radii:
    script = scriptIn.format(radius=r) # replaced input parameters
    with open("simulation.py","w") as f:
        f.write(script)
    cmd = "{} -n -x simulation.py {}".format(yade,r)
    p = subprocess.Popen(cmd.split(),stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
    p.wait()
    with open("m.dat") as f:
        f.readline()
        m = f.readline().strip()
    print("radius",r,"mass",m)
###

run as
python runner.py

instead of
radii = [1,2,3]
for r in radii: ...
you can of course implement more interesting logic (otherwise yade-batch makes more sense for fixed set of parameters)

Cheers
Jan

Revision history for this message
Mithushan Soundaranathan (mithushan93) said :
#4

Hi Jan,

Thank you very much.
I am getting error message: No such file or directory yadeDaily

Best,
Mithu

Revision history for this message
Jan Stránský (honzik) said :
#5

both python and linux are case sensitive. I wrote yadedaily, not yadeDaily
In the script, I used 'yade' variable, which is the name of your yade executable (yadedaily for my test).
Replace it with the name you normally use to start yade.
Jan

Revision history for this message
Mithushan Soundaranathan (mithushan93) said :
#6

Hi Jan,

I dowloaded Yade from the source code, would that impact it?

Best,
Mithu

Revision history for this message
Jan Stránský (honzik) said :
#7

> would that impact it?
no

Revision history for this message
Mithushan Soundaranathan (mithushan93) said :
#8

Hi Jan,

I was using O.reset on my regular code, without update (reset after simulation is done). It didn't work, the software just shut down.
I just replaced the O.pause() with O.reset()

Best,
Mithu

Revision history for this message
Jan Stránský (honzik) said :
#9

So probably you did not use it correctly (hard to tell without any code [6]).
Something like this should work:
###
# input ... one input data set
for input from inputs: # or somehow differently given input data
    O.reset()
    # materials, bodies, ...
    O.engines = [ ... ]
    O.run(); O.wait() # or some other stop condition
    # save
    # possibly modify input from here w.r.t results
###

Cheers
Jan

[6] https://www.yade-dem.org/wiki/Howtoask

Can you help with this problem?

Provide an answer of your own, or ask Mithushan Soundaranathan for more information if necessary.

To post a message you must log in.