2D biaxial compression task completion
Dear Jan Stránský:
Thanks for helping me to finish this task and I can accomplish all the process of 2D biaxial compression simulation, from preprocessing to postprocessing, using this script that is shown as follows for others to reference.
### fundamental details of application ###
# unicode: UTF-8
Filename=
from yade import pack,os
#######
### prescribing variables and functions for simulation controller ###
# material defination
spheremat = O.materials.
wallmat = O.materials.
# walls defination
mn,mx=Vector3(
wallIds=
# ThreeDTriaxialE
triax01=
wall_bottom_
wall_left_
wall_back_
wall_front_
internalCompac
stressControl_1 = True, stressControl_2 = True,stressCont
computeStressS
sigma_iso = 1.25e5,
sigma1 = 1.25e5,
sigma2 = 1.25e5,
sigma3 = 1.25e5,
strainRate1 = 0.01,strainRate2 = 0.01,
)
# ThreeDTriaxialE
triax02=
wall_bottom_
wall_left_
wall_back_
wall_front_
internalCompac
stressControl_1 = True, stressControl_2 = False,stressCon
computeStressS
sigma_iso = 1.25e5,
sigma1 = 1.25e5,
sigma2 = 1.25e5,
# sigma3 = 1.25e5,
strainRate1 = 0.001,strainRate2 = 0.15,
)
# Simulation stop conditions defination
def checkUnbalanced():
unb=
meanS=
q=unb
r=abs(
if q<0.01 and r<1e-5:
O.pause()
#######
# particles generation
O.periodic=1
O.cell.
sp=pack.
sp.makeCloud(
sp.toSimulation
# determining colors for particles in different aeras of the cell
for b in O.bodies:
if isinstance(
pos = b.state.pos
if pos[0] <3.5 and pos[1] < 3.5: b.shape.color = (1,0,0) # area 1
elif pos[0] >= 3.5 and pos[1] <3.5: b.shape.color = (0,1,0) # area 2
elif pos[0] >= 3.5 and pos[1] >= 3.5: b.shape.color = (0,0,1) # area 3
else: b.shape.pos = (1,1,0) # area 4
O.periodic=0
# blockedDOFs
for b in O.bodies:
if isinstance(
b.state.
# Simulation assembly for the first step
O.engines=[
ForceResetter(),
InsertionSortC
InteractionLoop(
[Ig2_
[Ip2_
[Law2_
),
GlobalStiffnes
triax01,
NewtonIntegrat
PyRunner(
]
# first step of simulation startting with a correct inheriting for the next step
O.dt = 2e-4
O.run(); O.wait()
# loading inheriting
O.load(
# Simulation assembly for the second step
O.engines=[
ForceResetter(),
InsertionSortC
InteractionLoop(
[Ig2_
[Ip2_
[Law2_
),
GlobalStiffnes
triax02,
NewtonIntegrat
]
# second step of simulation startting
O.dt = 2e-4
O.run(20000,True);
# whole task over
O.save(
O.wait()
#######
f = file("/
f.write('# This is the result data of 2D simulation\n\n')
f.write('# There are 8 types of varibles in this data as follows:\n\n')
f.write(
f.write('%-16s %-16s %-16s %-16s %-16s %-16s %-16s %-16s\n'% ('X-cordinate'
for b in O.bodies:
if isinstance(
pos = b.state.pos
rad = b.shape.radius
displ = b.state.displ()
f.write(
f.close()
def rename():
global Filename
os.
rename()
After this script showing, I have two problems to ask you as that:
(1). This script can almost do all the things the simulation need to do except the module "determining colors for particles in different aeras of the cell". After using these cammands, the colors of area 1 to area 3(only one color for each area) are differently assigned but area 4 has no reaction to this requirement that it comes in a variety of colors. I don not know why and desire your suggestion.
(2).The script can run well but is too long and inconvenient, but now I have almost no experience to optimize it using Python, please give me some advises for this purpose.
SEEKING YOUR HELP!
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Jan Stránský
- Solved:
- Last query:
- Last reply: