-
Noels Ludovic authoredNoels Ludovic authored
- Stochastic Finite Element Method (SFEM)
- Table of Contents
- Dependencies and Prerequisites
- Instructions using apt & pip3 package manager
- python, pandas and dependencies
- matplotlib, texttabble and latextable
- Pytorch (only for run with cm3Libraries)
- Structure of Repository
- generateRF
- rnnRF
- cellRF
- Example of application
- Generate the Gauss-points list and mesh structure for the random field generator
- Generate Random Fields
- Vizualize the random vector distribution
- Vizualize the random field distribution
- Run a MC Stochastic finite element simulation
- Disclaimer
Stochastic Finite Element Method (SFEM)
This repository contains:
- A spectral generator of random fields (RF) 1.
- Scripts to vizualize of the random fields.
- 2 test cases of random fiels generation and 1 test case of Monte-Carlo (MC) stochastic finite element simulations (SFEM).
Table of Contents
Dependencies and Prerequisites
-
Python, pandas, matplotlib, texttabble and latextable are pre requisites for visualizing and navigating the data.
-
For generating mesh and for vizualization, gmsh (www.gmsh.info) is required.
-
For running simulations, cm3Libraries (http://www.ltas-cm3.ulg.ac.be/openSource.htm) is required.
Instructions using apt & pip3 package manager
Instructions for Debian/Ubuntu based workstations are as follows.
python, pandas and dependencies
sudo apt install python3 python3-scipy libpython3-dev python3-numpy python3-pandas
matplotlib, texttabble and latextable
pip3 install matplotlib texttable latextable
Pytorch (only for run with cm3Libraries)
pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
Structure of Repository
- generateRF contains all the scripts used to generate and vizualize the random fields
- cellRF contains an example in which we generate a single variable random field on a lattice unit cell
- rnnRF contains an example in which we generate a correlated two-dimension random field and the siulations script to run Monte Carlo simulations on a multiscale lattice compression using a MOAMMM stochastic neural network as surrogate of the cell response.
generateRF
-
generateRF.py: file used to generate the random fields
- The RF is defined from the mean and standard deviation of the variables as well as from their correlation following for example for a 2-dimension RF:
-
meanX = np.array([0.5,10])
# mean of variables -
stdX = np.array([0.05,0.1])
# std of variables rho = 0.2
-
R0_XY = np.array([[1, rho], [rho, 1]])
#correlation matrix
-
- And from a the correlation lengths along the 3 direction
-
lc = [15., 15., 15.]
# correlation length
-
- The number of RFs to be generated follows from
- Nsim =10
- The Random fields will be generated at the spatial points defined in terms of their coordinates.
- The script tries to read a file in
mechDir+'/GPData'
, wheremechDir
is the working directory, describing the list of spatial points. One example of points coordinates can be found in rnnRF/GPData/coordinate_P_ZZ_OnPhysical_11.csv stored following: finite element number (for a FE simulation); 3 coordinates; point number in finite element (for a FE simulation). - The random field number
X
is saved in the filemechDir+'/randomFields/RandField_X.csv'
, wheremechDir
is the working directory. The number of columns is the dimension of the random vector and the number of lines is the number of spatial points. One example of generated 2-dimension RF can be found in rnnRF/randomFields/RandField_0.csv. - The random field number
X
along with the spatial points coordinates is saved in the filemechDir+'/randomFields/RandField_And_GP_X.csv'
, wheremechDir
is the working directory. The number of columns is the dimension of the random vector plus the 3 spatial coordinates and the number of lines is the number of spatial points. One example of generated 2-dimension RF can be found in rnnRF/randomFields/RandField_And_GP_0.csv.
- The script tries to read a file in
- The variable
recomputePDF=True
forces the evaluation of the spectral density matrix, which will be saved inmechDir+'/randomFields/H_pdf.dat'
. - The variable
recomputePDF=False
reads the spectral density matrix already saved inmechDir+'/randomFields/H_pdf.dat'
- The RF is defined from the mean and standard deviation of the variables as well as from their correlation following for example for a 2-dimension RF:
-
plotRF.py: file used to vizualize the distribution of the random vector.
- Reads the
N
random fields of type'RandField_X.csv'
found inmechDir+'/randomFields/'
, wheremechDir
is the working directory. Examples of generated 2-dimension RFs can be found in rnnRF/randomFields/. - Plot the distribution of the random vector.
- Reads the
-
vizualizeRF.py: file used to generate a gmsh (www.gmsh.info) compatible file to vizualize the random fields
- Reads the
N
random fields of type'RandField_And_GP_X.csv'
found inmechDir+'/randomFields/'
, wheremechDir
is the working directory. Examples of generated 2-dimension RFs can be found in rnnRF/randomFields/. - Uses the mesh structure of the considered application. The script tries to read stress file in
mechDir+'/GPData'
, wheremechDir
is the working directory, describing the elements structure. One example of stress file can be found in rnnRF/GPData/stress_step1.msh. - The random field number
X
is saved in format compatible with gmsh (www.gmsh.info) in the filemechDir+'/randomFields/RandField_X.msh'
, wheremechDir
is the working directory. One example of generated 2-dimension RF can be found in rnnRF/randomFields/RandField_0.msh.
- Reads the
- utilRF.py: set of functions used by the RF generator and vizualization files.
rnnRF
- rubics.geo: geometry file of a cube to be read by gmsh (www.gmsh.info).
- rubics.msh: mesh file of a cube generated by gmsh (www.gmsh.info).
- macro_cpp.py: multiscale lattice compression script to be run with cm3Libraries (http://www.ltas-cm3.ulg.ac.be/openSource.htm) and using a MOAMMM stochastic neural network as surrogate of the cell response.
- Bounds.dat: Bounds of the neural network model.
- model.dat: torch neural network model.
-
generateGPInfo.py: generate the Gauss points coordinates and mesh structure to be used by the random field generator. It requires cm3Libraries (http://www.ltas-cm3.ulg.ac.be/openSource.htm).
- The script write the Gauss points coordinates in the directory
'rnnRF/GPData'
. One example of points coordinates can be found in rnnRF/GPData/coordinate_P_ZZ_OnPhysical_11.csv stored following 3 coordinates, point number and point volume (for a FE simulation). - The script write the mesh structure in the directory
'rnnRF/GPData'
. One example of stress file can be found in rnnRF/GPData/stress_step1.msh.
- The script write the Gauss points coordinates in the directory
- runMCTest.py: Monte Carlo simulations on a multiscale lattice compression using a MOAMMM stochastic neural network as surrogate of the cell response. It requires cm3Libraries (http://www.ltas-cm3.ulg.ac.be/openSource.htm).
- The script uses the
N
random fields of type'RandField_And_GP_X.csv'
found inrnnRF/randomFields/'
. Examples of 2-dimension RFs can be found in rnnRF/randomFields/. - The script saves the simulations results in
'rnnRF/results/RandField_And_GP_X.csv/'
- plotMC.py: vizualize the different force displacement curves of the MC simulations.
- The script reads the simulations results saved in
'rnnRF/results/RandField_And_GP_X.csv/'
cellRF
- 80017_3_128.geo: geometry file of a lattice cell to be read by gmsh (www.gmsh.info).
- 80017_3_128.msh: mesh file of a lattice cell generated by gmsh (www.gmsh.info).
- MaterialProperties.csv PA12 viscoelastic-viscoplastic properties, see MOAMMM cell simulations.
- rve_solver.py: interface with cm3Libraries (http://www.ltas-cm3.ulg.ac.be/openSource.htm).
- strainPath80017.csv: loading path applied on the cell, see MOAMMM cell simulations.
- runthread.py: script to be run to simulate the cell loading case. Deterministic in this example. It requires cm3Libraries (http://www.ltas-cm3.ulg.ac.be/openSource.htm).
Example of application
In this example, we consider a multiscale lattice simulation in which the lattice cell response is substituted by a MOAMMM stochastic neural network acting as a surrogate. To this end we generate 10 random fields of correlated cell length and struts radius. MC siulations can then be conducting.
Generate the Gauss-points list and mesh structure for the random field generator
This steps requires cm3Libraries (http://www.ltas-cm3.ulg.ac.be/openSource.htm). From the rnnRF directory, run
python3 generateGPInfo.py
After execution the ouput files are store in 'rnnRF/GPData'
:
- The script write the Gauss points coordinates in the directory
'rnnRF/GPData'
. One example of points coordinates can be found in rnnRF/GPData/coordinate_P_ZZ_OnPhysical_11.csv stored following 3 coordinates, point number and point volume (for a FE simulation). - The script write the mesh structure in the directory
'rnnRF/GPData'
. One example of stress file can be found in rnnRF/GPData/stress_step1.msh.
Generate Random Fields
From the generateRF directory, select testNb=1
for 'rnnRF'
in the file generateRF.py and then run
python3 generateRF.py
After execution the ouput files are store in 'rnnRF/randomFields'
:
- The random field number
X
is saved in the file'rnnRF/randomFields/RandField_X.csv'
. The number of columns is the dimension (2) of the random vector and the number of lines is the number of spatial points. One example of generated 2-dimension RF can be found in rnnRF/randomFields/RandField_0.csv. - The random field number
X
along with the spatial points coordinates is saved in the file'rnnRF/randomFields/RandField_And_GP_X.csv'
. The number of columns is the dimension (2) of the random vector plus the 3 spatial coordinates and the number of lines is the number of spatial points. One example of generated 2-dimension RF can be found in rnnRF/randomFields/RandField_And_GP_0.csv.
Vizualize the random vector distribution
From the generateRF directory, select testNb=1
for 'rnnRF'
in the file plotRF.py and then run
python3 plotRF.py
Vizualize the random field distribution
From the generateRF directory, select testNb=1
for 'rnnRF'
in the file vizualizeRF.py and then run
python3 vizualizeRF.py
After execution the ouput files are store in 'rnnRF/randomFields'
:
- The random field number
X
is saved in format compatible with gmsh (www.gmsh.info) in the file'rnnRF/randomFields/RandField_X.msh'
. One example of generated 2-dimension RF can be found in rnnRF/randomFields/RandField_0.msh.
Then, from rnnRF directory run
gmsh rubics.msh randomFields/RandField_*.msh
to vizualize the RF discretization compatible with the geometry.
Run a MC Stochastic finite element simulation
This steps requires cm3Libraries (http://www.ltas-cm3.ulg.ac.be/openSource.htm). From the rnnRF directory, run
python3 runMCTest.py
After execution the ouput files are store in 'rnnRF/results'
:
- The script saves the simulations results in
'rnnRF/results/RandField_And_GP_X.csv/'
To vizualize the different resulting stress/strain curves
python3 plotMC.py
Disclaimer
Code related to MOAMMM project This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 862015.
Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union. Neither the European Union nor the granting authority can be held responsible for them.
-
The random field generator is described in:
"Noels, L. (2022). Toward stochastic multi-scale methods in continuum solid mechanics Advances in Applied Mechanics, 55, 1-254. doi:10.1016/bs.aams.2022.03.001" which can be downloaded here. Please note the erratum of the official version. We would be grateful if you could cite this publication in case you use the files. ↩