# How to get the Volume in the simulation with periodic boundary condition?

Asked by panjinhong on 2019-03-24

Hello, everyone.

I use PeriTriaxController to have a simulation with periodic boundary condition. But I don't know how to measure the volume change. It seems a silly problem, but I need your help!

Actually, when I use a Cube with 30,000 particles to do the simulation, I can not keep the boundary's shape (I want to keep it in as a flat at each surface). Is there any way to achieve my demand？

Looking forward to your help. Thanks!

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
panjinhong
Solved:
2019-03-26
Last query:
2019-03-26
2019-03-25
 Jan Stránský (honzik) said on 2019-03-24: #1

Hello,

> But I don't know how to measure the volume change.

dV = refVolume - O.cell.volume # [1], absolute value
or
dV = 1.0 - O.cell.trsf.determinant() # O.cell.trsf is deformation gradient, google e.g. "deformation gradient volume change", in range [0,1]

> I can not keep the boundary's shape (I want to keep it in as a flat at each surface).

Please be more specific.
In fact, as the simulation is periodic, there is no "boundary" or "surface"..

cheers
Jan

 panjinhong (pjh20000) said on 2019-03-25: #2

Thank you, Jan.

By the second question, I mean that when I output the position of all the particle (by state.pos) and observed it in paraview, it become strange.

But I want it to like a cuboid, because I want to calculate the stress inside and the unevenness of the boundary cause lots of troubles.

Jinhong

 Jan Stránský (honzik) said on 2019-03-25: #3

> when I output the position of all the particle (by state.pos) and observed it in paraview, it become strange.

export not b.state.pos, but O.cell.wrap(b.state.pos), see [1]. state.pos may have arbitrary value in space, likely outside the periodic cell. O.cell.wrap shifts the positions to be something like cuboid.

> But I want it to like a cuboid, because I want to calculate the stress inside and the unevenness of the boundary cause lots of troubles.

you can compute stress as getStress() [2] or PeriTriaxController.stress [3]. The "boundary" (once more, no boundary exist) is irrelevant here.

cheers
Jan

 panjinhong (pjh20000) said on 2019-03-26: #4

Thank you！

To post a message you must log in.