Tell me about the batch method

Asked by 内山康太郎

Tell me about the " batch method "

I would like to create a batch method Periodic triaxial test, but it is not calculated accurately.

Could you please modify the program?

###############################################
#batch text
rMean
.05
.10
.15
###############################################

###############################################
#Periodic triaxial test
readParamsFromTable(rMean=.05)
# make rMean, rRelFuzz, maxLoad accessible directly as variables later
from yade.params.table import *

sigmaIso = -200e3

#import matplotlib
#matplotlib.use('Agg')

# generate loose packing
from yade import pack, plot

O.periodic = True
sp = pack.SpherePack()
if 1:
 ## uniform distribution
 sp.makeCloud((0, 0, 0), (0.25, 0.25, 0.2), rMean=rMean, rRelFuzz=.2, periodic=True)
else:
 ## create packing from clumps
 # configuration of one clump
 c1 = pack.SpherePack([((0, 0, 0), .03333), ((.03, 0, 0), .017), ((0, .03, 0), .017)])
 # make cloud using the configuration c1 (there could c2, c3, ...; selection between them would be random)
 sp.makeClumpCloud((0, 0, 0), (2, 2, 2), [c1], periodic=True, num=500)

# setup periodic boundary, insert the packing
sp.toSimulation()

O.engines = [
        ForceResetter(),
        InsertionSortCollider([Bo1_Sphere_Aabb()]),
        InteractionLoop([Ig2_Sphere_Sphere_ScGeom()], [Ip2_FrictMat_FrictMat_FrictPhys()], [Law2_ScGeom_FrictPhys_CundallStrack()]),
        PeriTriaxController(
                label='triax',
                # specify target values and whether they are strains or stresses
                goal=(sigmaIso, sigmaIso, sigmaIso),
                stressMask=7,
                # type of servo-control
                dynCell=True,
                maxStrainRate=(10, 10, 10),
                # wait until the unbalanced force goes below this value
                maxUnbalanced=.1,
                relStressTol=1e-3,
                # call this function when goal is reached and the packing is stable
                doneHook='compactionFinished()'
        ),
        NewtonIntegrator(damping=.2),
        PyRunner(command='addPlotData()', iterPeriod=10),
]
O.dt = .5 * PWaveTimeStep()

def addPlotData():
 plot.addData(
         unbalanced=unbalancedForce(),
         i=O.iter,
         sxx=triax.stress[0],
         syy=triax.stress[1],
         szz=triax.stress[2],
         exx=triax.strain[0],
         eyy=triax.strain[1],
         ezz=triax.strain[2],
         # save all available energy data
         Etot=O.energy.total(),
         **O.energy
 )

# enable energy tracking in the code
O.trackEnergy = True

# define what to plot
plot.plots = {
        'i': ('unbalanced',),
        'i ': ('sxx', 'syy', 'szz'),
        ' i': ('exx', 'eyy', 'ezz'),
        # energy plot
        ' i ': (O.energy.keys, None, 'Etot'),
}
# show the plot
plot.plot()

def compactionFinished():
 # set the current cell configuration to be the reference one
 O.cell.trsf = Matrix3.Identity
 # change control type: keep constant confinement in x,y, 20% compression in z
 triax.goal = (sigmaIso, sigmaIso, -.2)
 triax.stressMask = 3
 # allow faster deformation along x,y to better maintain stresses
 triax.maxStrainRate = (1., 1., .1)
 # next time, call triaxFinished instead of compactionFinished
 triax.doneHook = 'triaxFinished()'
 # do not wait for stabilization before calling triaxFinished
 triax.maxUnbalanced = 10

def triaxFinished():
 plot.saveDataTxt(O.tags['id'] + '.txt')
 waitIfBatch()
 O.pause()
###############################################

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
Robert Caulk (rcaulk) said :
#1

>I would like to create a batch method Periodic triaxial test, but it is not calculated accurately.

Hello, what does "not calculated accurately" mean?

Please attach full log output, including the error. [1]

Cheers,

Robert

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

Revision history for this message
内山康太郎 (kenkoutaro) said :
#2

Thanks for the reply.

This is the error message
Three files are created for each batch, and an example (rMean=0.05) is shown below.

###################################################
TCP python prompt on localhost:9002, auth cookie `udkyse'
Welcome to Yade 2022.01a
Using python version: 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
Warning: no X rendering available (see https://bbs.archlinux.org/viewtopic.php?id=13189)
XMLRPC info provider on http://localhost:21002
Running script 3ziku0306re.py
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
yade.plot: creating fake plot, since there are no y-data yet

=================== JOB SUMMARY ================
id : rMean=.05
status : 0 (OK)
duration: 00:00:01
command : YADE_BATCH=1re.table:2 DISPLAY= /usr/bin/yade-double --threads=1 --nice=10 -x 3ziku0306re.py> 3ziku0306re.py.rMean=.05.log 2>&1
started : Sat Mar 11 16:41:40 2023
finished: Sat Mar 11 16:41:41 2023
###################################################

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

> but it is not calculated accurately.

Instant replay:
> Hello, what does "not calculated accurately" mean?

> This is the error message
> status : 0 (OK)

there is no error

Please provide more info (what is the problem, how to reproduce it, what should be the correct behavior, ...)

Cheers
Jan

Revision history for this message
内山康太郎 (kenkoutaro) said :
#5

From the example(Oedometric test,Batch table [1]), I confirmed that the log file and the result file are output.
However, my program outputs only the log file.

I also wanted to create a batch file with a different radius, so I created a program, but it only created a log file.
Can you please tell me what is wrong with the program?

Also, What does status : 0 (OK) mean?

[1]https://yade-dem.org/doc/tutorial-examples.html#oedometric-test

Revision history for this message
内山康太郎 (kenkoutaro) said :
#6

I was able to assemble a complete file.
I leave it here for your reference.

###################################################
#batch table
rMean
.008
.009
.010
###################################################

###################################################
#Program file

#encoding: utf-8 # periodic triaxial test simulation
# The initial packing is either
#
# 1. random cloud with uniform distribution, or
# 2. cloud with specified granulometry (radii and percentages), or
# 3. cloud of clumps, i.e. rigid aggregates of several particles
#
# The triaxial consists of 2 stages:
#
# 1. isotropic compaction, until sigmaIso is reached in all directions;
#    this stage is ended by calling compactionFinished()
# 2. constant-strain deformation along the z-axis, while maintaining
#    constant stress (sigmaIso) laterally; this stage is ended by calling
#    triaxFinished()
#
# Controlling of strain and stresses is performed via PeriTriaxController,
# of which parameters determine type of control and also stability
# condition (maxUnbalanced) so that the packing is considered stabilized
# and the stage is done.
#
readParamsFromTable(rMean=.008)
# make rMean, rRelFuzz, maxLoad accessible directly as variables later
from yade.params.table import * sigmaIso = -200e3 #import matplotlib
#matplotlib.use('Agg') # generate loose packing
from yade import pack,  plot O.periodic = True
sp = pack.SpherePack()
if 1:
    ## uniform distribution
    sp.makeCloud((0, 0, 0), (0.25, 0.25, 0.2), rMean=rMean, rRelFuzz=.2, periodic=True)
else:
    ## create packing from clumps
    # configuration of one clump
    c1 = pack.SpherePack([((0, 0, 0), .03333), ((.03, 0, 0), .017), ((0, .03, 0), .017)])
    # make cloud using the configuration c1 (there could c2, c3, ...; selection between them would be random)
    sp.makeClumpCloud((0, 0, 0), (2, 2, 2), [c1], periodic=True, num=500) # setup periodic boundary, insert the packing
sp.toSimulation() O.engines = [
        ForceResetter(),
        InsertionSortCollider([Bo1_Sphere_Aabb()]),
        InteractionLoop([Ig2_Sphere_Sphere_ScGeom()], [Ip2_FrictMat_FrictMat_FrictPhys()], [Law2_ScGeom_FrictPhys_CundallStrack()]),
        PeriTriaxController(
                label='triax',
                # specify target values and whether they are strains or stresses
                goal=(sigmaIso, sigmaIso, sigmaIso),
                stressMask=7,
                # type of servo-control
                dynCell=True,
                maxStrainRate=(10, 10, 10),
                # wait until the unbalanced force goes below this value
                maxUnbalanced=.1,
                relStressTol=1e-3,
                # call this function when goal is reached and the packing is stable
                doneHook='compactionFinished()'
        ),
        NewtonIntegrator(damping=.2),
        PyRunner(command='addPlotData()', iterPeriod=10),
]
O.dt = .5 * PWaveTimeStep()
def addPlotData():
    plot.addData(
            unbalanced=unbalancedForce(),
            i=O.iter,
            sxx=triax.stress[0],
            syy=triax.stress[1],
            szz=triax.stress[2],
            exx=triax.strain[0],
            eyy=triax.strain[1],
            ezz=triax.strain[2],
            # save all available energy data
            Etot=O.energy.total(),
            **O.energy
    )
# enable energy tracking in the code
O.trackEnergy = True # define what to plot
plot.plots = {
        'i': ('unbalanced',),
        'i ': ('sxx', 'syy', 'szz'),
        ' i': ('exx', 'eyy', 'ezz'),
        # energy plot
        ' i ': (O.energy.keys, None, 'Etot'),
}
# show the plot
plot.plot()
def compactionFinished():
    # set the current cell configuration to be the reference one
    O.cell.trsf = Matrix3.Identity
    # change control type: keep constant confinement in x,y, 20% compression in z
    triax.goal = (sigmaIso, sigmaIso, -.2)
    triax.stressMask = 3
    # allow faster deformation along x,y to better maintain stresses
    triax.maxStrainRate = (1., 1., .1)
    # next time, call triaxFinished instead of compactionFinished
    triax.doneHook = 'triaxFinished()'
    # do not wait for stabilization before calling triaxFinished
    triax.maxUnbalanced = 10
def triaxFinished():
    plot.saveDataTxt(O.tags['id'] + '.txt')
    O.pause() O.run()
waitIfBatch() O.saveTmp()
###################################################

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

> Also, What does status : 0 (OK) mean?

this means that the "result" of that one simulation was OK. By convention, the numerical return code return code of successful program is 0 (search something like "program return code convention").
Non-zero values would mean some error during running.

> I was able to assemble a complete file.
> I leave it here for your reference.

Thanks, but please make it working, especially without syntax errors, .e.g line below
from yade.params.table import * sigmaIso = -200e3 #import matplotlib

> However, my program outputs only the log file.
> Can you please tell me what is wrong with the program?

Obviously syntax errors are wrong.

Otherwise (assuming this is some copy-paste newline problem), I don't know.
I have run your simulation and it did export data files sucessfully (e.g. for my case 20230315T150806p19057.txt)

What exactly is "the result file"?

Cheers
Jan

Can you help with this problem?

Provide an answer of your own, or ask 内山康太郎 for more information if necessary.

To post a message you must log in.