# How to implement periodic boundary conditions for a soil model in FLAC3D

**URL:** <https://forum.itascainternational.com/t/how-to-implement-periodic-boundary-conditions-for-a-soil-model-in-flac3d/2140>\
**Category:** FLAC3D\
**Created:** [June 20, 2025, 4:29pm UTC](https://forum.itascainternational.com/t/how-to-implement-periodic-boundary-conditions-for-a-soil-model-in-flac3d/2140 "2025-06-20T16:29:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Alsadah](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@Ahmed\_Alsadah](https://forum.itascainternational.com/u/Ahmed_Alsadah)\
**Post date:** [June 20, 2025, 4:29pm UTC](https://forum.itascainternational.com/t/how-to-implement-periodic-boundary-conditions-for-a-soil-model-in-flac3d/2140/1 "2025-06-20T16:29:32Z")

</div>

Hello,

I’m working on a soil model in FLAC3D and would like to apply periodic boundary conditions to simulate a repeating unit cell.

The goal is to simulate a repeating soil domain, where opposite boundaries act as if connected — so that displacements and forces are equal and consistent across them.

Could anyone share guidance, examples, or recommended FISH routines for setting up periodic boundaries properly in FLAC3D (7)?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![EmirhanAltinok](https://avatars.discourse-cdn.com/v4/letter/e/58f4c7/32.png) [@EmirhanAltinok](https://forum.itascainternational.com/u/EmirhanAltinok)\
**Post date:** [June 21, 2025, 6:39am UTC](https://forum.itascainternational.com/t/how-to-implement-periodic-boundary-conditions-for-a-soil-model-in-flac3d/2140/2 "2025-06-21T06:39:40Z")

</div>

Hi Ahmed,

I’m using FLAC2D at the moment, and I’ve written a small code to apply periodic boundary conditions in 2D. Maybe it could help you if you adapt it to FLAC3D. Here’s the code:

fish define PeriodicBC(gPnt,gpGroup,gpSlot)  
global M\_xMin, M\_xMax, \_Attach\_List  
global ModelSize = M\_xMax-M\_xMin  
if gp.isgroup(gPnt,gpGroup,gpSlot)  
local pos1 = gp.pos(gPnt)  
local pos2 = pos1 + vector(ModelSize,0)  
local id1 = gp.id(gp.near(pos1))  
local id2 = gp.id(gp.near(pos2))  
command  
zone attach gridpointid [id2] to-gridpointid [id1]  
endcommand  
endif  
end

zone gridpoint group ‘bound=left’ range p-x [M\_xMin] tol 1e-3  
zone gridpoint group ‘bound=right’ range p-x [M\_xMax] tol 1e-3

[PeriodicBC(::gp.list,‘left’,‘bound’)]

---

<div class="post-metadata">

**Author:** ![Ahmed\_Alsadah](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@Ahmed\_Alsadah](https://forum.itascainternational.com/u/Ahmed_Alsadah)\
**Post date:** [June 22, 2025, 11:00pm UTC](https://forum.itascainternational.com/t/how-to-implement-periodic-boundary-conditions-for-a-soil-model-in-flac3d/2140/3 "2025-06-22T23:00:55Z")

</div>

Thank you very much, i used the following code and it succeded in attaching the gridpoints:  
fish define attach\_x\_periodic  
; Attach gridpoints from xmin to corresponding xmax positions  
local gp, x0, x1, pos\_target, gp\_target, id1, id2  
loop foreach gp gp.list  
x0 = 0.0  
x1 = 1.7  
if math.abs(gp.pos.x(gp) - x0) \< 1e-5 then  
pos\_target = vector(x1, gp.pos.y(gp), gp.pos.z(gp))  
gp\_target = gp.near(pos\_target)  
id1 = gp.id(gp)  
id2 = gp.id(gp\_target)  
command  
zone attach gridpointid [id1] to-gridpointid [id2] snap off  
endcommand  
endif  
endloop  
end  
[attach\_x\_periodic]  
fish define attach\_y\_periodic\_no\_corners  
local gp, y0, y1, pos\_target, gp\_target, id1, id2  
y0 = 0.0 ; ymin  
y1 = 1.7 ; ymax

```
loop foreach gp gp.list
    if math.abs(gp.pos.y(gp) - y0) < 1e-5 then
        if math.abs(gp.pos.x(gp) - 0.0) > 1e-5 then
            if math.abs(gp.pos.x(gp) - 1.7) > 1e-5 then
                pos_target = vector(gp.pos.x(gp), y1, gp.pos.z(gp))
                gp_target = gp.near(pos_target)
                id1 = gp.id(gp)
                id2 = gp.id(gp_target)
                command
                    zone attach gridpointid [id1] to-gridpointid [id2] snap off
                endcommand
            endif
        endif
    endif
endloop

```

end  
[attach\_y\_periodic\_no\_corners]  
But now i have another problem, I had static boundaries before attachments, when I try to remove them and do model solve, it does not converge.
