Couple Escript with ESyS-Particle and Suggestions to install software properly
Dear All,
Could someone please be so kind to email me the paper "Coupled Finite Element and Particle Based Simulations" ? The paper could be found in the website http://
As I'd like to do a mutiscale modelling in a way like that in the thread https:/
Besides, could someone please give me some suggestion on properly installing ESyS-particle and Escript such that these two software could be coupled?
Best regards,
Jiadun
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Lutz Gross
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
I have forwarded you a copy of the paper.
You should be able to install escript and esys-particle on top of each other into the same diretory "esys/". The order might be critical but if there is a problem this would be in esys/__init__.py. We haven't done this for a while and I assume you need to switch off MPI for escript. Please don;t ask me for a script how to link the codes.
Revision history for this message
|
#2 |
Thanks Lutz Gross, that solved my question.
Revision history for this message
|
#3 |
Hi Lutz Gross,
Currently I'm running coupled Escript-
Multiprocessing is used in the Escript to arrange the independent ESyS-Particle simulation by call('mpirun -np 2 `which esysparticle` load.py', shell=True).
Now I want to run the coupled simulation on more than one nodes.
I have asked this question https:/
Howevery, if I used the method method mentioned above using mpi4py, then I have to turn MPI for Escript, which will contradict
with the MPI of ESyS-Particle.
Could you please give me some suggestion?
Best regards,
Jiadun
Revision history for this message
|
#4 |
In principle you can launch escript using mpirun and mpi4py. The run-escript shell is just for convenience to deal with different mph flavors, threading, etc. However it is vital that mpi4py, esys-particle and encrypt are linked against the same mpi shared libraries.
Revision history for this message
|
#5 |
The otehr thing the launcher does is to add the underlying C++ libraries and escript python libs to LD_LIBRARY_PATH and PYTHONPATH.
(Usually esys/ and lib/ under the install location).
So make sure you've made the appropriate adjustments.
Revision history for this message
|
#6 |
Thank you very much for your help.
I'll try it.
Revision history for this message
|
#7 |
This question was expired because it remained in the 'Open' state without activity for the last 15 days.
Revision history for this message
|
#8 |
Hi Lutz Gross and Joel Fenwick,
I think that mpi is properly turned on for escript. However I have problem where I need your help.
Details to show that MPI option is correctly installed. The problem is at the end of this thread.
(1) [bwjliu@int2 Escript_MPI]$ run-escript
Python 2.7.9 (default, Mar 9 2015, 11:04:54)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from esys.lsm import *
>>> from esys.escript import *
>>> from mpi4py import MPI
>>>
(2)[bwjliu@int2 Escript_MPI]$ run-escript -p 24 example01a.py
Expected Number of time outputs is: 200.0
time step 1 at t=9.131063e+01 days completed. total energy = 1.554331e+14.
time step 2 at t=1.826213e+02 days completed. total energy = 1.554331e+14.
time step 3 at t=2.739319e+02 days completed. total energy = 1.554331e+14.
time step 4 at t=3.652425e+02 days completed. total energy = 1.554331e+14.
time step 5 at t=4.565531e+02 days completed. total energy = 1.554331e+14.
time step 6 at t=5.478637e+02 days completed. total energy = 1.554331e+14.
time step 7 at t=6.39174
(3) refer to https:/
Here totalFormulatio
[bwjliu@int2 FDEM_2_T_MPI]$ run-escript totalFormulatio
8
-1.99206367725
CSubLatticeCont
CSubLatticeCont
CSubLatticeCont
CSubLatticeCont
CSubLatticeCont
CSubLatticeCont
CSubLatticeCont
CSubLatticeCont
slave started at local/global rank 0 / 1
slave started at local/global rank 0 / 1
slave started at local/global rank 0 / 1
slave started at local/global rank 0 / 1
set time step to 0
set time step to 0
set time step to 0
set time step to 0
reading reading 502 RotFriction interactions
reading 503 RotFriction interactions
reading 504 RotFriction interactions
slave started at local/global rank 0 / 1
set time step to 0
reading 504 RotFriction interactions
504 RotFriction interactions
slave started at local/global rank 0 / 1
constructing FieldMaster for field e_kin
constructing FieldMaster for field e_kin
set time step to 0
constructing FieldMaster for field e_kin
reading 499 RotFriction interactions
4e+02 days completed. total energy = 1.554331e+14.
The detail of the problem is
[bwjliu@int2 FDEM_2_T_MPI]$ run-escript -p 16 totalFormulatio
4
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
lengthHeigh
lengthHeigh
RuntimeError: Error - Data::getValueO
lengthHeigh
RuntimeError: Error - Data::getValueO
lengthHeigh
RuntimeError: Error - Data::getValueO
lengthHeigh
RuntimeError: Error - Data::getValueO
lengthHeigh
RuntimeError: Error - Data::getValueO
RuntimeError: Error - Data::getValueO
lengthHeigh
RuntimeError: Error - Data::getValueO
Traceback (most recent call last):
File "totalFormulati
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
lengthHeigh
lengthHeigh
Traceback (most recent call last):
File "totalFormulati
RuntimeError: Error - Data::getValueO
RuntimeError: Error - Data::getValueO
lengthHeigh
RuntimeError: Error - Data::getValueO
lengthHeigh
lengthHeigh
RuntimeError: Error - Data::getValueO
RuntimeError: Error - Data::getValueO
lengthHeigh
RuntimeError: Error - Data::getValueO
lengthHeigh
RuntimeError: Error - Data::getValueO
lengthHeigh
RuntimeError: Error - Data::getValueO
lengthHeigh
RuntimeError: Error - Data::getValueO
application called MPI_Abort(
application called MPI_Abort(
application called MPI_Abort(
application called MPI_Abort(
application called MPI_Abort(
application called MPI_Abort(
application called MPI_Abort(
application called MPI_Abort(
Best regards,
Jiadun
Revision history for this message
|
#9 |
Without knowing your code in details, I would guess that problem is in assumed numbering of data points. Data objects are distributed over the available process, ie. when you object has N data points then under np ranks each rank holds roughly N/np data points where for some data objects a data overlap is introduced. So my guess is that the i loop around the d.getTupleForDa
Revision history for this message
|
#10 |
Thanks Lutz Gross, that solved my question.
Revision history for this message
|
#11 |
Hi Lutz Gross,
It seems that there are some functions which are not mpi safe when running Escript by using run-escript -p NP some.py.
From example
(Function(
d.getTupleForDa
d.setValueOfDat
How to avoid it?
Revision history for this message
|
#12 |
Correct, these functions are not MPI-safe and hence users are not encouraged to use them (eg. they are not listed in the users guide). An appropriate replacement depends on the context?
Revision history for this message
|
#13 |
Hi Lutz Gross,
I'm running a coupled FEM-DEM simulation similar to https:/
Coefficients need to be set for Gauss Points like https:/
Best regards,
Jiadun
Revision history for this message
|
#14 |
The question is what <everything you want to do with in_loc > means. Can you point me to the point where this happens in your code?
Revision history for this message
|
#15 |
Hi Lutz Gross,
Here is beginning part of the code, the problem comes up at the for loop where displacement is set.
from esys.escript import *
from esys.escript.
from esys.finley import ReadMesh,Rectangle
from numpy import zeros,ones
from esys.escript import util
from esys.pycad import * #domain constructor
from esys.pycad.gmsh import Design #Finite Element meshing package
import numpy,os,
from esys.weipa import saveVTK
from esys.escript.
from subprocess import call #call shell command
import multiprocessing #run DEM in turn
from mpi4py import MPI
comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()
## record start time
start = time.time()
# make sure path exists
save_path= os.path.
mkDir(save_path)
def runOdem(num):
os.chdir(
call('mpirun -np 2 `which esysparticle` PLoad2.
os.chdir(base_dir)
def runIdem(num):
os.chdir(
call('mpirun -np 2 `which esysparticle` PLoadRestart2.
os.chdir(base_dir)
rho = 0.00169254697901
lx = 400.0
ly = 800.0
dom = Rectangle(
#dom = ReadMesh(
base_dir = os.getcwd()
#print (Function(
GaussNum = 8
ProcessesNum = GaussNum
###copy converged stress fromlast step
for i in range(GaussNum):
call('cp Cdem_{0:
call('cp Cdem_{0:
#dom = ReadMesh(
pde = LinearPDESystem
#pde = LinearPDE(
pde.getSolverOp
pde.setSymmetryOn()
pde.setValue(
local_damping_a = Vector(
CauchyStress=
NominalStress=
stressOld = Tensor(
R = Tensor(
U = Tensor(
F = Tensor(
F = Tensor(
E = Tensor(
macroRotation = Scalar(
averageRotation = Scalar(
#stress=
xInitial = dom.getX()
##From biaxialSmooth YADE FEMXDEM
proj = Projector(dom)
sig = proj(CauchyStress) # project Gauss point value to nodal value
sig_bounda = interpolate(
traction = matrix_
Bx = FunctionOnBound
bottomSurf = whereZero(Bx[1])
topSurf = whereZero(
rightSurf = whereZero(
leftSurf = whereZero(Bx[0])
tractTop = traction*topSurf # traction at top surface
forceTop = integrate(
lengthTop = integrate(
v_last = Vector(
d_last = Vector(
d = Vector(
#######
## DR parameter
DR= True
alpha = 2.0
XI = 0.005
safeFactor = 0.9
tol = 1.0e-2
rtol = 1.0e-2
totalSteps = 0
loadingSteps = 0
openfilename = "runTime.data"
openfile = open(openfilena
run_time = openfile.
openfile.close()
for i in range(len(
totalSteps += float(run_
#######
#######
###read displacement from Isotropic compression to calculate delt_d
bottomBeginNode = 0
bottomEndNode = 1
topBeginNode = 4
topEndNode = 5
openfilename = "iso_disp.data"
openfile = open(openfilena
disp_iso = openfile.
openfile.close()
for i in xrange(6):
d.setValueOfDa
run-escript -p 6 totalFormulatio
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
Traceback (most recent call last):
File "totalFormulati
d.setValueO
d.setValueO
d.setValueO
RuntimeError: RuntimeError: DataExpanded:
RuntimeError: DataExpanded:
DataExpanded:
d.setValueO
RuntimeError: d.setValueOfDat
DataExpanded:
RuntimeError: DataExpanded:
d.setValueO
RuntimeError: DataExpanded:
application called MPI_Abort(
application called MPI_Abort(
application called MPI_Abort(
application called MPI_Abort(
application called MPI_Abort(
application called MPI_Abort(
Best regards,
Jiadun
Revision history for this message
|
#16 |
The relevant code fragment is
######
###read displacement from Isotropic compression to calculate delt_d
openfilename = "iso_disp.data"
openfile = open(openfilena
disp_iso = openfile.
openfile.close()
for i in xrange(6):
d.setValueOfDa
Revision history for this message
|
#17 |
Question: where is the 6 in xrange(6) coming from?
Revision history for this message
|
#18 |
dom = Rectangle(
So there are 6 nodes.
Revision history for this message
|
#19 |
This is tricky business as it is not really possible to predict on which processor a node or element will end up (plus there can be overlapping). However there is a so called reference ID which is assigned to each node or element and which is unique across all ranks. This is number is set by the first column in the node as well as the element sections of the fly file (see users guide.)
for i in xrange(6):
d.setValueO
getReferenceIDF
Revision history for this message
|
#20 |
This is tricky business as it is not really possible to predict on which processor a node or element will end up (plus there can be overlapping). However there is a so called reference ID which is assigned to each node or element and which is unique across all ranks. This is number is set by the first column in the node as well as the element sections of the fly file (see users guide.). If you use Rectangle IDs are generated by counting along the x axis.
assuming that the first column in "iso_disp.data" defines the reference number then your code would like like:
v={}
for l in disp_iso:
v[
for i in xrange(6):
id=
d.setValueO
A similar technique you can apply to elements.
Revision history for this message
|
#21 |
I tried the method above. Here is the result.
[bwjliu@int1 setEscriptDisp]$ run-escript -p 2 setDisp.py
Traceback (most recent call last):
File "setDisp.py", line 22, in <module>
Traceback (most recent call last):
File "setDisp.py", line 22, in <module>
d.setValueO
d.setValueO
RuntimeError: RuntimeError: DataExpanded:
application called MPI_Abort(
File setDisp.py
from esys.escript import *
from esys.finley import Rectangle
lx = 400.0
ly = 800.0
dom = Rectangle(
## displacement
d = Vector(
openfilename = "iso_disp.data"
openfile = open(openfilena
disp_iso = openfile.
openfile.close()
##set disp
v={}
for i in range(len(
v[int(
for i in xrange(6):
Id=d.getFuncti
d.setValueOfDa
#print Id
##write disp to check
DISP = FileWriter(
for i in range(d.
DISP.write(
+str(
+str(
DISP.close()
exit()
File iso_disp.data
0 0.0 0.0
1 -1.80853237932 0.0
2 0.286888846683 -1.40356468889
3 -1.51239344602 -1.77001262807
4 0.80758326687 -2.92594370955
5 -0.982979988092 -3.42311449366
Revision history for this message
|
#22 |
The line "for i in xrange(6):" should be read as "for i in xrange(
Revision history for this message
|
#23 |
After using for i in xrange(
[bwjliu@int2 Escript_MPI]$ more setDisp.py
from esys.escript import *
from esys.finley import Rectangle
lx = 400.0
ly = 800.0
dom = Rectangle(
## displacement
d = Vector(
openfilename = "iso_disp.data"
openfile = open(openfilena
disp_iso = openfile.
openfile.close()
v={}
for i in range(len(
v[int(
sp_iso[
for i in xrange(
Id=d.getFuncti
d.setValueOfDa
print i, Id
DISP = FileWriter(
for i in xrange(
DISP.write(
+str(
+str(
DISP.close()
exit()
[bwjliu@int2 Escript_MPI]$ run-escript -p 2 setDisp.py
0 0
1 1
2 2
[bwjliu@int2 Escript_MPI]$ more disp_check.data
0 0.0 0.0
1 -1.80853237932 0.0
2 0.286888846683 -1.40356468889
Revision history for this message
|
#24 |
FileWriter writes data from rank 0 only!
Revision history for this message
|
#25 |
Is it possible to write all node displacements to a file when running simulation with more than 1 processes?
Revision history for this message
|
#26 |
You can try saveDataCSV (see 3.2.10 in the users guide). Unfortunately the reference number is not written into the file but
d = Vector(
ref=Scalar(0., Solution(dom))
for i in xrange(
Id=
d.setValueO
ref.
saveDataCSV(
I have fired a feature request to add the reference number to the file.
Revision history for this message
|
#27 |
Thank you so much for helping me solve the setValueOfDataP
Revision history for this message
|
#28 |
Thanks Lutz Gross, that solved my question.