# erase rigid boundaries and add periodic boundaries

Hi,
I met a question when building the model.
I have two scripts and they should run in sequence.
The first script is used to generate particles. The particles expand until the wallstress reach 90kPa. The walls are rigid.
In the second script, I want to erase the rigid walls and replace them by the periodic boundaries, but I don’t know how to add the periodic boundaries after executing the following command

###erase the six rigid boundaries###
for b in range(6):
O.bodies.erase(b)

The first script:
#########################################
### Defining parameters and variables ###
#########################################

#Material constants
Density = 3000
FrictionAngle = 1.5
PoissonRatio = 0.5
Young = 300e6
Damp = 0.5
N_particles = 4000

#Wall constants
WDensity = 0
WFrictionAngle = 0.0
WPoissonRatio = 0.5
WYoung = 50e9

#Packing variables
mn = Vector3(1,0,0)
mx = Vector3(101,20,1)

#Confining variables
ConfPress1 = -90000 #pre-compression
ConfPress = -1.0e5

#time calculation
startT = O.time
endT = O.time
timeSpent = endT - startT

########################################
#import necessary packages
import matplotlib; matplotlib.rc('axes',grid=True)
import pylab

########################################
### Sample Preparing ###################
########################################

#Create materials for spheres and plates
SphereMat = O.materials.append(FrictMat(young = Young, poisson = PoissonRatio, frictionAngle = radians(FrictionAngle), density = Density))
WallMat = O.materials.append(FrictMat(young = WYoung, poisson = WPoissonRatio, frictionAngle = radians(WFrictionAngle), density = WDensity))

#Create walls for packing
wallIds = O.bodies.append(aabbWalls([mn,mx],thickness=0.001,material=WallMat))

sp = pack.SpherePack()

sp.toSimulation(material = SphereMat)

O.usesTimeStepper=True
O.trackEnerty=True
#################################
#####Defining triaxil engines####
#################################

###first step: compression#######
triax1=TriaxialStressController(
wall_back_activated = False, #for 2d simulation
wall_front_activated = False,
thickness = 0.001,
maxMultiplier=1.+1.5e5/Young, # spheres growing factor (fast growth)
finalMaxMultiplier=1.+4e3/Young,
internalCompaction = True, # If true the confining pressure is generated by growing particles
computeStressStrainInterval = 10,

goal1 = ConfPress1,
goal2 = ConfPress1,
)

newton=NewtonIntegrator(damping=Damp)

###engine
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8, defaultDt=4*utils.PWaveTimeStep()),
triax1,
newton,
PyRunner(realPeriod=10,command='checkUnbalanced()',label='check'),
]
# Simulation stop conditions defination
def checkUnbalanced():
unb=unbalancedForce()
if unb<0.001:
O.pause()

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
Last query:
 Revision history for this message  Jan Stránský (honzik) said on 2022-04-06: #1

Hello,

have a look at periodic tutorial example .

There are a few essential commands:

enabling periodicity:
O.periodic = True

setting periodic cell size:
O.cell.hSize = Matrix3(2, 0, 0, 0, 2, 0, 0, 0, 2)

setting periodic cell deformation:
O.cell.velGrad = Matrix3(-.1, 0, 0, 0, -.1, 0, 0, 0, -.1)

The topic of switching from walls to periodicity was already discussed IMO, but I cannot find it..
Just be aware, that from the wall simulation, the sample is not periodic and putting it then to periodicity may have some "negative effect", mainly in the "non-periodic seam" region.

Cheers
Jan

 Revision history for this message William (qfxx-123) said on 2022-04-06: #2

Thanks Jan Stránský, that solved my question.