yade install problem
Hello, I was trying install yade but at the step ''cmake -DCMAKE_
Thanks.
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Welcome to yade!
Is there a reason you are compiling from sources? Since you are new to yade, I recommend installing yadedaily from prebuilt packages to become familiar with the software before moving on to compiling from sources. This can be achieved simply with the following commands:
sudo bash -c 'echo "deb http://
wget -O - http://
sudo apt-get update
sudo apt-get install yadedaily
(note, you will want to replace xenial with your distribution).
That error is telling you that it wants to find the file CMakeLists.txt in /home/tanvir/
I am guessing you created a folder called "trunk" and then cloned yade inside of it. Am I right? This would mean your path to sources is actually:
/home/tanvir/
Or maybe you did not clone yade at all? In which case you will want to start the installation guide [1] from the beginning and follow each step.
Revision history for this message
|
#2 |
Hi, thank your for your reply. I want to install yadedaily.
sudo bash -c 'echo "deb http://
wget -O - http://
sudo apt-get update
sudo apt-get install yadedaily
is this command sufficient for all the procedure or do I need follow prerequisites, compilation and all other steps?
Revision history for this message
|
#3 |
Yes, that series of commands is sufficient, assuming you are using a debian or ubuntu distribution of linux.
Revision history for this message
|
#4 |
Just a comment, for Ubuntu (preferably a newer version like 16.04), you can install yade just by
sudo apt-get install yade
Jan
Revision history for this message
|
#5 |
my version is ubuntu16.04.. I have install yade using ''sudo apt-get install yade''. now I am trying to run a python script of but getting following error,
Welcome to Yade 1.20.0
TCP python prompt on localhost:9000, auth cookie `dksesy'
XMLRPC info provider on http://
Running script 20160108Periodi
Traceback (most recent call last):
File "/usr/bin/yade", line 182, in runScript
execfile(
File "20160108Period
from nsmp1d_
ImportError: No module named nsmp1d_
/home/tanvir/
"You should import from traitlets.config instead.", ShimWarning)
/home/tanvir/
warn('As of IPython 5.0 `PromptManager` config will have no effect'
[[ ^L clears screen, ^U kills line. F12 controller, F11 3d view (use h-key for showing help), F10 both, F9 generator, F8 plot. ]]
Is there any possibility that yade is not installed properly? Or do I need to install something else along with yade?
Revision history for this message
|
#6 |
Hi Tanvir,
it seems that Yade is installed correctly. The problem seems to be inside your script, namely:
File "20160108Period
from nsmp1d_
ImportError: No module named nsmp1d_
could you please include the content of your script? Also please read [1]
Sometimes this error is present even if the module imported is inside the directory where yade is started. In this case
import sys
sys.path.
might help..
cheers
Jan
Revision history for this message
|
#7 |
Hi Jan, here is the script.
#New version, amelioration wrt 20150715 :
#- IMPORTANT Modify the length of the vector evaluated from ndimz to ndimz. Works with Yade6 and is not adapted to the other cases
#- Add a limiter to avoid negative tau transmitted to the fluid (unphysical and source of numerical instabilities
#- Add a new configuration for the turbulentFluctu
#- Add an option for fluidProfile imposed case.
#- Register the averaged velocity of the part1 and 2 in twoSize mode (Yade6)
#If activated, adapt the script to the associated computer path
Cluster = 0
philippeComputer = 0
julienComputer = 0
lamiaComputer = 0
raphaelComputer = 0
#Import libraries
from yade import pack, plot
import math
import random as rand
import numpy as np
np.set_
import yade.timing
import pylab as pyl
from matplotlib import pyplot as pyp
import matplotlib.gridspec as gridspec
#Register the path for later use (tests + save)
scriptPath = os.path.
##
## Main parameters of the simulation
##
diameterPart = 6e-3 #Diameter of the particles, in meter
densPart = 2500 #density of the particles, in kg/m3
waterDepth = 7. #Water depth in diameter
ndimz = 525 #Number of cells in the height
from nsmp1d_
lengthCell = 15 #Streamwise length of the periodic cell
widthCell = 15 #Spanwise length of the periodic cell
Nlayer = 10. #nb of layer of particle, in diameter
fluidHeight = (Nlayer+
quasi2D = 0
twoSize = 0
#If twoSize option activated, overwrite the previous input #tanvir
if twoSize:
Nlayer1 = 10 #nb of layer of particle type 1
Nlayer2 = 1 #nb of layer of particle type 2
diameterPart1 = 6e-3 #Diameter of the particles type 1, in meter
diameterPart2 = 4e-3 #Diameter of the particles type 2, in meter
fluidHeight = Nlayer1*
diameterPart = diameterPart1 #Size 1 taken as reference
#Fluid library importation and precisions
phiPartMax = 0.61 #Value of the maximum volume fraction used for the thresholding
##
## Option of the simulation
##
#Imposed fluid profile? If yes, require to add a file fluid.py in the folder with inside the value of vxFluid vector + turbStress vector if you want to add turbulent fluctuations also.
imposedFluidPro = 0
#Temporary imposed profile: impose a fluid profile for 50 seconds (considered as equilibrium) and switch to the fluid resolution
initImposedFluidPro = 0
#Activation and choice of the fluid turbulent fluid velocity fluctuation. Cannot choose both. If none, will not apply fluct.
turbModel1 = 1
turbModel2 = 0
#Stress averaging: if activated, compute and save the stress tensor depth profile at each execution of measure()
stressSave = 0
pythonStressCal
#Option to put lateral walls, to break the biperiodicity and study the influence of walls.
lateralWalls = 0
#Option for time averaging of the DEM data before fluid resolution
timeAveraging = 0 #1 activated, 0 not activated
nbAv = 5. #number of averaging between the fluid resolution
#Averaging parameter : if activated, evaluate the average using python function partConcVelocity() instead of the C++ one
pythonAverage = 0
#debug stress mode, record all the quantities necessary to study the momentum balance in detail.
debugStress = 0
#Video
video = 1 #1, make a movie
if video:
snapshotEngine = 0 #To make the movie later using mencoder (require the qt.viewer open, obtain what you see)
paraview = 1 #To make the movie later using paraview (do not require the qt.viewer open, faster)
fps = 1. #frame per second #tanvir
##
## Secondary parameters of the simulation (less changed)
##
#Particles parameters
restitCoef = 0.5 #Restitution coefficient of the particles
partFrictAngle = atan(0.4) #friction angle of the particles, in radian
slope = 0.1 #Angle of the slope in radian #tanvir
# Fluid parameters
expoRZ = 3.1 # Richardson Zaki exponent for the hindrance function of the drag
dpdx = 0.0 #pressure gradient along streamwise direction
densFluid = 1000. #Density of the fluid
kinematicViscoFluid = 1e-6 #kinematic viscosity of the fluid
# Fluid simulation parameters (RANS), see fluidResolution function
dsig = np.zeros(ndimz)
dz = fluidHeight/
sig=pyl.
for i in range(ndimz-1): # calcul du pas d'espace
dsig[i] = sig[i+1] - sig[i]
#In order to fasten the script, some correspondance are supposed. Should be respected otherwise it does not work well
dtFluid = 1e-5 #Time step for the fluid resolution
fluidResolPeriod = 1e-2 #1/fluidResolPeriod = frequency of the calculation of the fluid profile
measurePeriod = (1e-1)*5 # We perform measurement every measurePeriod seconds #tanvir
savePeriod = 1e1 # We save the simulation (to be able to reload) every savePeriod seconds.
#Quasi 2D option
if quasi2D ==1:
print '\nQuasi 2D option activated\n'
lateralWalls = 1
widthCell = 6.5/6.
phiPartMax = 0.51
print 'phiPartMax = 0.51\n'
#
## Tests on the script
#
#Width check and Value of the fluid library and size of the system
if widthCell<2 and phiPartMax>0.6:
if widthCell<=1:
print 'Impossible to run simulation with width exactly equal to the diameter particle size !\n'
exit()
else:
print '\nCareful !! Uncoherence between the 2D character and the value of phiPartMax !! \n'
#Value of ndimz and dz
if ndimz != int(round(
print('\n!!Problem dz = d/{0} !!\nUse ndimz = {1} instead to have dz = d/30 (and change accordingly the fluid library import)
# if quasi2D!=1:
# exit()
#Option compatibility
if measurePeriod<
print '\nNot possible to have measurePeriod<
exit()
turbModel = 0
if turbModel1 ==1 or turbModel2==1:
turbModel = 1
if turbModel1 ==1 and turbModel2==1:
print "It is not possible to have the two fluctuations model in the same time ! \n Modify turbModel1 or turbModel2"
exit()
#Reloading simulation
reloadingSimulation = 0
if os.path.
reloadingSimul
##
## Initialization of the parameters
##
# Averaging/Save
vxPart = np.zeros(ndimz) # streamwise particle velocity depth profile
vyPart = np.zeros(ndimz) # spanmwise particle velocity depth profile
vzPart = np.zeros(ndimz) # normal particle velocity depth profile
qsMean = 0 #Mean bead flux
dragTerm = np.zeros(ndimz) # drag term transmitted to the fluid vector
averageDrag = np.zeros(ndimz) # drag field vector
stressProfile = getStressProfil
positionPartX = np.zeros(
positionPartZ = np.zeros(
velocityPartX = np.zeros(
velocityPartZ = np.zeros(
if twoSize:
phiPart1 = np.zeros(ndimz) # Concentration vector
vxPart1 = np.zeros(ndimz) # streamwise particle velocity depth profile
vyPart1 = np.zeros(ndimz) # spanwise particle velocity depth profile
vzPart1 = np.zeros(ndimz) # wall-normal particle velocity depth profile
phiPart2 = np.zeros(ndimz) # Concentration vector
vxPart2 = np.zeros(ndimz) # streamwise particle velocity depth profile
vyPart2 = np.zeros(ndimz) # spanwise particle velocity depth profile
vzPart2 = np.zeros(ndimz) # wall-normal particle velocity depth profile
#Initialization of the variables necessary for timeAveraging option
if timeAveraging:
n_dt = 1.
vxPart_dt = np.zeros(ndimz)
phiPart_dt = np.zeros(ndimz)
averageDrag_dt = np.zeros(ndimz)
if twoSize:
phiPart1_dt = np.zeros(ndimz)
averageDrag1_dt = np.zeros(ndimz)
vxPart1_dt = np.zeros(ndimz)
vyPart1_dt = np.zeros(ndimz)
vzPart1_dt = np.zeros(ndimz)
phiPart2_dt = np.zeros(ndimz)
averageDrag2_dt = np.zeros(ndimz)
vxPart2_dt = np.zeros(ndimz)
vyPart2_dt = np.zeros(ndimz)
vzPart2_dt = np.zeros(ndimz)
#Parameter initialized only if it is the initial simulation, otherwise they are charged
if reloadingSimulation !=1:
#Parameters which should be loaded and not initiallized if we recover the simulation
phiPart = np.zeros(ndimz) # Concentration vector
turbulentViscosity = np.zeros(ndimz) # Turbulent viscocity
waterDepth = 0.0 #Water depth : height of the "clear" water
vxFluid = np.zeros(ndimz) # Fluid velocity at time step n
turbStress = np.zeros(ndimz) #Turbulent stress vector
fileNumber = 0 #counter to save the files
#######
## PARAMETERS DECLARATION##
#######
#Geometrical configuration, define useful quantities
height = 5*fluidHeight #heigth of the periodic cell, bigger than the real height to take into account jumps
length = lengthCell*
width = widthCell*
gravityVector = Vector3(
gravityVectorAp
groundPosition = height/4.0
VLayer = dz*length*width #Volume of a layer
partVolume = pi/6.*pow(
if twoSize:
partVolume1 = partVolume
partVolume2 = pi/6.*pow(
#Particles contact law parameters
maxPressure = (densPart-
normalStiffness = maxPressure*
youngMod = normalStiffness
poissonRatio = 0.5 #poisson's ratio of the particles. Classical values, not much influence (see ref in Da Cruz et al 2005)
if twoSize:
youngMod1 = normalStiffness
youngMod2 = normalStiffness
O.materials.
O.materials.
#Material
O.materials.
# if it is the initial simulation create the framework and the simulation loop, otherwise load it
if reloadingSimulation !=1:
######
## FRAMEWORK CREATION (sphere, wall,...)##
######
#Definition of the semi-periodic cell
O.periodic = True
O.cell.
#To be compatible with lateral walls
leftLimitY = 0.0
rightLimitY = width
centerLimitY = width/2.0
#If lateralWalls, add the walls and increase the cell size to avoid particle touching the walls to appear on the other side
if lateralWalls:
#Warn the user
print '\nlateralWalls option activated: mono-periodic boundary condition only !\n'
#Increase the cell size
O.cell.
#Modify accordingly the position of the center of the cell and the wall right and left position
leftLimitY = diameterPart
rightLimitY = width+diameterPart
centerLimitY = diameterPart + width/2.0
#Define the wall and add to the simulation
sidePlaneL = box(center= (length/
sidePlaneR = box(center= (length/
O.bodies.
if quasi2D == 1:
# Regular arrangement of spheres sticked at the bottom with random height
a = range(0,
for b in a: #loop creating a set of sphere sticked at the bottom with a (uniform) random altitude comprised between 0.5 (diameter/12) and 5.5mm (11diameter/12) with steps of 0.5mm. The repartition is made around groundPosition. Exactly the same set up as the one from the experiment.
n = rand.randrange(
O.bodies.
else:
#Execute the file containing the database which is a 2D list containing the positions and radius of the particles composing the random fixed bed. Each position x,y (integer) contain a list of particle with position and radius at this place
if Cluster==1:
pathFixedBot = '/home/maurin/'
elif philippeCompute
pathFixedBot = '/home/
elif tanvir==1:
pathFixedBot = '/home/
elif julienComputer==1:
pathFixedBot = '/home/
elif lamiaComputer==1:
pathFixedBot = '/home/
elif raphaelComputer:
pathFixedBot = '/home/
else:
print '\nNo precised computer used ! Cannot resolve the fixed bottom file path accordingly ! Precise the computer used at line 12\n'
exit()
if diameterPart==6e-3:
if lengthCell>= 10:
execfile(
else:
execfile(
print '\n Use the short database for random fixed bottom generation ! \n Be careful, polydisperse bottom !\n'
elif diameterPart==3e-3:
execfile(
elif diameterPart=
execfile(
else:
print '\nno fixed bottom of the right size !! quit the simulation ! \n'
exit()
xMax = len(fixedBottom
yMax = len(fixedBottom
x = rand.randrange(
y = rand.randrange(
#Starting from the random x and y position, loop over the length and width of the require fixed bed increasing x and y position (in diameterPart). Create then a sphere starting from 0 for x and y.
for i in range(0,
for j in range(0,
for k in fixedBottomData
O.
# Ground reference and Wall on the side
lowPlane = box(center= (length/
WaterSurface = box(center= (length/
O.bodies.
#Count the initial number of particles (for later check)
initNumber = len(O.bodies)
#Create a loose cloud of particle inside the cell
partCloud = pack.SpherePack()
if twoSize:
diameterPart = diameterPart1
partVolume = partVolume1
Nlayer = Nlayer1
#Define the number of particle from the density of particle per unit length
if quasi2D==1:#to keep the correspondance with previous work where I putter NbPart = Nl*L/d
partNumber = int(Nlayer*
else:
partNumber = int(Nlayer*
#Define the deposition height considering that the packing realised by make cloud is 0.2
depositionHeight = Nlayer*
#Create a cloud of partNumber particles
partCloud.
#Send this packing to simulation with material Mat
partCloud.
partNumber += initNumber
#Same for a second size of particles
if twoSize:
partCloud2 = pack.SpherePack()
if quasi2D==1:#to keep the correspondance with previous work where I putter NbPart = Nl*L/d
partNumber2 = int(Nlayer2*
else:
partNumber2 = int(Nlayer2*
#Define the deposition height considering that the packing realised by make cloud is 0.2
depositionHeight2 =Nlayer2*
partCloud2.
partCloud2.
#Increment the counters for check and deposition time input
depositionHei
partNumber+
#Evaluate the deposition time considering the free-fall time of the highest particle to the ground (overestimation)
depoTime = sqrt(deposition
#Check
if len(O.bodies)
print '\nProblem : too low number of beads in the sample compared with what was asked !\n'
exit()
# Collect the ids of the spheres which are dynamic and to which we should add the hydroforce
dv =1e-2 #Scale of the velocity imposed to the particle, no influence if not extreme case en = 1
idApplyForce = []
for b in O.bodies:
if isinstance(
if widthCell<2: #For the quasi 2D case, need to push slightly the spheres randomly in order to break the 2D configuration
deltaV = - dv + rand.uniform(
b.state.
idApplyForce
######
#### SIMULATION LOOP#####
######
O.engines = [
# Reset the forces
ForceResetter(),
# Detect the potential contacts
InsertionSort
# Calculate the different interactions
InteractionLoop(
[Ig2_
[Ip2_
[Law2_
,label = 'interactionLoop'),
#Apply an hydrodynamic force to the particles
HydroForceEng
#Time averaging of the DEM data for fluid resolution
PyRunner(command = 'timeAveragingD
#Calculate the fluid profile using the routine
PyRunner(command = 'fluidResolutio
#Calculate the turbulent fluctuations from a DRW random walk model
PyRunner(command = 'turbulentFluct
#Measurement, output files
PyRunner(command = 'measure()', virtPeriod = measurePeriod, label = 'measurement', dead = True),
# Check if the packing is stabilized, if yes activate the hydro force on the grains and the slope.
PyRunner(
#GlobalStiffn
GlobalStiffne
# Integrate the equation and calculate the new position/
NewtonIntegra
]
#save the initial configuration to be able to recharge the simulation starting configuration easily
O.saveTmp()
#run
O.run()
#Add engines to make a video
if video:
if snapshotEngine:
print '\n video snapshot activated : takes snapshot of the qt.view as you see it\n'
O.pause()
O.engines += [SnapshotEngine
elif paraview:
print '\n video paraview activated : register vtk file for later use of paraview (video...)\n'
O.engines += [VTKRecorder(
else:
print '\nBe careful the video is not activated : need to specify snapshotEngine or paraview value.\n'
O.pause()
#Add a pyRunner to re-activate the fluctuations at 50s
if initImposedFlui
O.engines += [PyRunner(
# else, it is a reloading of simulation, we load the necessary parameters and the simulation
else :
execfile(
O.load(scriptPath + '/save.xml') #load the simulation where it stopped
print '\n RELOAD THE PREVIOUS SIMULATION\n'
if imposedFluidPro==1 or initImposedFlui
execfile(
#######
#######
#######
###### ######
### LET THE TIME FOR THE GRAVITY DEPOSITION AND ACTIVATE THE FLUID AT THE END ###
###### ######
def gravityDepositi
#At the very start, unbalanced force can be low as there is only few contacts, but it does not mean the packing is stable
#The rest will be run only if O.time>lim = estimation of the deposition time
if O.time<lim : return
else :
newton.damping = 0.0
packing.dead = True # Remove the present engine for the following
addFluidForce
fluidResol.dead = False # Activate the fluid profile resolution
# O.timingEnabled = True # Activate a function to check the time taken by the different function
# If option activated, Activate the turbulent fluctuation calculation
if turbModel==1:
turbFluct.dead = False
# If option activated, activate the function to perform cumulated time averaging on DEM for fluidResol
if timeAveraging:
timeAve.dead = False
#If twoSize C++ option activated, express the size of the two particles in the engine for later averaging
if twoSize and pythonAverage!=1:
addFluidForc
addFluidForc
addFluidForc
if imposedFluidPro==1 or initImposedFlui
fluidResol.dead = True #Force no fluid resolution
addFluidForc
addFluidForc
else:
#Initialization of the fluid resolution
fluidResolut
measurement.dead = False # Activate the Measurement
return
###############
#######
############# ###################
# Activate the fluid resolution. Used only when initImposedFluidPro option activated ###
############# ###################
def activateFluidRe
global initImposedFluidPro
if O.time>50:
fluidResol.dead = False #Activate the fluid resolution
initImposedFl
actFlResol.dead = True #Kill the engine
#######
#######
############## Function to time-average the DEM data transmitted to fluid resolution ###########
#######
def timeAveragingDE
global phiPart_dt
global vxPart_dt
global averageDrag_dt
global phiPart1_dt
global averageDrag1_dt
global vxPart1_dt
global vyPart1_dt
global vzPart1_dt
global phiPart2_dt
global averageDrag2_dt
global vxPart2_dt
global vyPart2_dt
global vzPart2_dt
global n_dt
#Re-initialized at each new averaging step
if n_dt==0:
vxPart_dt = np.zeros(ndimz)
phiPart_dt = np.zeros(ndimz)
averageDrag_dt = np.zeros(ndimz)
if twoSize:
phiPart1_dt = np.zeros(ndimz)
averageDrag1_dt = np.zeros(ndimz)
vxPart1_dt = np.zeros(ndimz)
vyPart1_dt = np.zeros(ndimz)
vzPart1_dt = np.zeros(ndimz)
phiPart2_dt = np.zeros(ndimz)
averageDrag2_dt = np.zeros(ndimz)
vxPart2_dt = np.zeros(ndimz)
vyPart2_dt = np.zeros(ndimz)
vzPart2_dt = np.zeros(ndimz)
#Evaluate the average vx,vy,vz,phi,drag profiles and store it in addFluidForce
addFluidForce.
#Store the values in
phiPart_dt += np.array(
vxPart_dt += np.array(
averageDrag_dt += np.array(
if twoSize:
phiPart1_dt += np.array(
averageDrag1_dt += np.array(
vxPart1_dt += np.array(
vyPart1_dt += np.array(
vzPart1_dt += np.array(
phiPart2_dt += np.array(
averageDrag2_dt += np.array(
vxPart2_dt += np.array(
vyPart2_dt += np.array(
vzPart2_dt += np.array(
n_dt+=1.
###############
#######
################ #######
########## EVALUATE THE TURBULENT FLUCTUATION ASSOCIATED TO EACH PARTICLE##########
################# #######
# Argument: ndimz, turbulentViscosity, vxFluid, phiPart,
# Modification : turbFluct.
addFluidForce.
addFluidForce.
addFluidForce.
addFluidForce.
def turbulentFluctu
global waterDepth
global turbStress
#For stability requirement at the initialization stage
if O.time<
print 'No turbulent fluctuation in the initialization process for stability reasons!'
turbFluct.
else:
# Evaluate nBed, the position of the bed which is assumed to be located around the first maximum of concentration when considering decreasing z.
nBed = 0.
bedElevation = 0.
for n in range(1,ndimz):
# if there is a peak and its value is superior to 0.5, we consider it to be the position of the bed
if phiPart[ndimz - n] < phiPart[ndimz - n-1] and phiPart[ndimz - n] > 0.5 :
nBed = ndimz - n
waterDepth = (ndimz-1 - nBed)*dz
bedElevation = fluidHeight - waterDepth #Evaluate the bed elevation for the following
break
#(Re)Define the bed elevation over which fluid turbulent fluctuations will be applied.
addFluidForce
#First turbulent fluctuation model: a unique constant lifetime for the turbulent fluctuation, flucTimeScale
if turbModel1:
vMeanAboveBed = sum(vxFluid[
flucTimeScale = waterDepth/
# New evaluation of the random fluid velocity fluctuation for each particle.
addFluidForc
turbFluct.
elif turbModel2:
# New evaluation of the random fluid velocity fluctuation for each particle.
addFluidForc
turbFluct.
addFluidForc
if O.time<depoTime+1: #To avoid important virtPeriod at the start, impose it for 1s. Fasten the transient.
turbFluct.
if turbModel2: addFluidForce.
###############
#######
###### ######
### CALL THE FLUID PROFILE RESOLUTION ROUTINE###
###### ######
#Arguments : ndimz, vxFluid, vxPart, dragTerm, densFluid, fluidHeight, sig, dsig, diameterPart, phiPartFluid, kinematicViscoF
#Modify : vxFluid, addFluidForce.
testFluidResol = 0 # Test variable for the fluid resolution
def fluidResolution
global phiPart
global vxPart
global vyPart
global vzPart
global vxFluid
global averageDrag
global turbulentViscosity
global testFluidResol
global dragTerm
global taufsi
global n_dt
global turbStress
if twoSize:
global averageDrag1
global phiPart1
global vxPart1
global vyPart1
global vzPart1
global averageDrag2
global phiPart2
global vxPart2
global vyPart2
global vzPart2
#Two different way of evaluating the average profiles: phiPart, vxPart, averageDrag, (+ same for 1 and 2 with twoSize)
#From python
if pythonAverage==1 or debugStress==1:
averageProfile()
#Or from C++
elif timeAveraging:#with multiple time averaging made previously in timeAveragingDE
#Normalize the time averaged data
vxPart = vxPart_dt/n_dt
phiPart = phiPart_dt/n_dt
averageDrag = averageDrag_dt/n_dt
if twoSize:
phiPart1 = phiPart1_dt/n_dt
averageDrag1 = averageDrag1_
vxPart1 = vxPart1_dt/n_dt
vyPart1 = vyPart1_dt/n_dt
vzPart1 = vzPart1_dt/n_dt
phiPart2 = phiPart2_dt/n_dt
averageDrag2 = averageDrag2_
vxPart2 = vxPart2_dt/n_dt
vyPart2 = vyPart2_dt/n_dt
vzPart2 = vzPart2_dt/n_dt
#And report the other one (for usual measurement)
vyPart = np.array(
vzPart = np.array(
n_dt = 0
else:#with simple time averaging
if raphaelComputer!=1:
#Evaluate the average vx,vy,vz,phi,drag profiles and store it in addFluidForce
addFluidForc
else:#On old ubuntu/Yade version, needs to do it differently:
#At next time step, Evaluate the average vx,vy,vz,phi,drag profiles and store it in addFluidForce
if testFluidResol == 0:
addFluidFor
fluidResol.
testFluidResol = 1
return
## Import the necessary average variables for the fluid resolution from addFluidForce : phiPart,vxPart, averageDrag
vxPart = np.array(
vyPart = np.array(
vzPart = np.array(
phiPart = np.array(
averageDrag = np.array(
#Back to the usual resolution period for next step
fluidResol.
fluidResol.
testFluidResol = 0 #Re-initialize the test
#If two particle size in the simulation, store complementary necessary average
if twoSize:
vCell = dz*width*length
#C++ function evaluating the depth profiles of solid volume fraction and solid velocities
phiPart1=
phiPart2=
averageDrag1
averageDrag2
vxPart1=
vxPart2=
vyPart1=
vyPart2=
vzPart1=
vzPart2=
#
## Prepare the variables for the fluid resolution
#
# Threshold the solid vol. fraction in the bed to remove the oscillations due to layering and avoid turbulence in the bed
phiPartFluid = np.zeros(ndimz)
for n in range(1,ndimz+1):
# If the concentration inside the bed reach the maximum concentration (imposed in the fluid solver). Then all the values of concentration under this one are going to be thresholded at phiPartMax, in order to damp the turbulence inside the bed.
if phiPart[ndimz - n] > phiPartMax:
for i in range(n,ndimz+1):
phiPartFlu
break
#Otherwise we report the normal value.
phiPartFluid[
#Density of particle per unit volume N/Vcell:
nPart = phiPart[
#Calculate the momentum transfer from the drag force interaction : N<fd>/Vcell
dragTerm = nPart*averageDr
if twoSize: #if two size, sum the two contributions n1<f1> + n2 <f2>, formulation necessary to keep energy conservation.
dragTerm = phiPart1[
#Create Taufsi/rhof = dragTerm/
taufsi = np.zeros(ndimz)
for i in range(1,ndimz):
urel = max(abs(vxFluid[i] - vxPart[i]),1e-5) #Limit the value to avoid division by 0
#Limit the max value of taufsi to the fluid resolution limit, i.e. 1/(10dt) and required positive (charact. time)
taufsi[i] = max(0,min(
#
## Call the routine for fluid resolution
#
[vxFluid_
#Debugstress option
if debugStress==1:
global taufsiBIS
taufsiBIS = np.zeros(ndimz)
for i in range(1,ndimz):
urel = max(abs(vxFluid[i] - vxPart[i]),1e-5)
taufsiBIS[i] = min(dragTermBIS
global vxFluid_before
vxFluid_before = vxFluid
vxFluid = vxFluid_np
path = scriptPath + '/'+ str(fileNumber)
globalParam = ['vxPart'
Save(path, globalParam)
#update
vxFluid = vxFluid_np
#Modify the velocity in the HydroForceEngine which apply the force
addFluidForce.
#Evaluate the turbulent shear stress for the turbulent fluctuations model and Shields number evaluation
turbStress = np.zeros(ndimz)
n = 0
for nu_t in turbulentViscos
turbStress[n] = nu_t*(vxFluid[
n+=1
addFluidForce.
###############
#######
####### ########
### OUTPUT ###
####### ########
#Function which register the different quantities asked for post processing
#Arguments : len(O.bodies), O.bodies, scriptPath, fileNumber, measurePeriod, savePeriod, qsMean, phiPart, vxPart, vxFluid, turbulentViscosity, dragTerm, waterDepth
#Modify : fileNumber, 'paramSave.py', 'save.xml'
def measure():
global fileNumber
global qsMean
global stressProfile
global vxPart
global vyPart
global vzPart
global phiPart
global averageDrag
global phiPart1
global phiPart2
global averageDrag1
global averageDrag2
global vxPart1
global vxPart2
global vyPart1
global vyPart2
global vzPart1
global vzPart2
if imposedFluidPro==1 or initImposedFlui
if pythonAverage==1 or debugStress==1:
averageProfile()
#Or from C++
else:
#Evaluate the average vx,vy,vz,phi,drag profiles and store it in addFluidForce
addFluidForc
#Replace it in the global python variables
vxPart = np.array(
vyPart = np.array(
vzPart = np.array(
phiPart = np.array(
averageDrag = np.array(
#If two particle size in the simulation, store complementary necessary average
if twoSize:
vCell = dz*width*length
#C++ function evaluating the depth profiles of solid volume fraction and solid velocities
phiPart1=
phiPart2=
averageDrag
averageDrag
vxPart1=
vxPart2=
vyPart1=
vyPart2=
vzPart1=
vzPart2=
# Save all the following variables/split in two file for faster post processing
if stressSave == 1:
if pythonStressCal
stressProfile = stressFieldCalc
else:
stressProfile = getStressProfil
for n in range(0,ndimz):
stressProfil
stressProfil
globalParam = ['stressProfile']
path = scriptPath + '/'+ str(fileNumber)
Save(path, globalParam)
#if necessary output file with the positions and velocities of the particles
if 0:
global positionPartX
global positionPartZ
global velocityPartX
global velocityPartZ
positionPartX = np.zeros(
positionPartZ = np.zeros(
velocityPartX = np.zeros(
velocityPartZ = np.zeros(
for b in O.bodies:
if isinstance(
positionPar
positionPar
velocityPar
velocityPar
path = scriptPath + '/'+ str(fileNumber)
globalParam = ['positionPartX', 'positionPartZ'
Save(path, globalParam)
#Evaluate the dimensionless sediment rate to save
qsMean = sum(phiPart*
path = scriptPath + '/'+ str(fileNumber)
globalParam = ['qsMean'
if twoSize:
globalParam =['qsMean'
Save(path, globalParam)
fileNumber +=1
#PHF if twoSize!=1 and O.time>=150:
# if O.time>=150:
# print '\n End of the simulation, simulated 150s as required !\n '
# O.pause()
# O.exitNoBacktrace()
#For reload, save sometimes the variables necessary to reload. (does not work anymore...)
if (fileNumber*
#Save the simulation of yade the global python parameter in order to be able to recover the simulation
O.save(scriptPath + '/'+'save.xml')
# Save the global parameters which shouldn't be initialized to zero at the reloading.
globalParam = ['phiPart'
Save(scriptPath + '/'+'paramSave.py', globalParam)
##
# Evaluation and printing of the Shields number or qsMean.
if imposedFluidPro==1 or initImposedFlui
print 'qsMean', qsMean
else:
if twoSize:
#Consider the average diameter in the layer in motion (which is the one to consider for Shields number)
dummy = np.where(
phi1Sum = sum(phiPart1[
phi2Sum = sum(phiPart2[
#Volume weighted average diameter: N1Vp1 d1 + N2Vp2 d2/(N1Vp1 + N2Vp2) (*VCell/VCell)
diameterMix = (diameterPart1*
else:
#Only one size in the simulation...
diameterMix = diameterPart
shieldsNumber = densFluid*
print 'Shields number', shieldsNumber
###############
#######
########## ##########
### EVALUATE THE MEAN VOLUME FRACTION, DRAG AND STREAMWISE VELOCITY OF THE PARTICLES IN FUNCTION OF THE DEPTH###
########## ##########
#Arguments : ndimz, dz, length, Vlayer, groundPosition, radius, phiPart
#Modify : phiPart, vxPart, averageDrag
def averageProfile():
global phiPart
global averageDrag
global vxPart
global vyPart
global vzPart
global qsMean
global phiPart1
global averageDrag1
global phiPart2
global averageDrag2
#Initialization of the concentration and the streamwise velocity. (two times the water height in order to take into account the particles which are also above the fluid in the concentration and velocity profile
phiPart_loc = np.zeros(ndimz) #Mean particle concentration in function of depth
vxPart_loc = np.zeros(ndimz) #Mean particle velocity in function of depth
vyPart_loc = np.zeros(ndimz) #Mean particle velocity in function of depth
vzPart_loc = np.zeros(ndimz) #Mean particle velocity in function of depth
averageDrag_loc = np.zeros(ndimz) #Mean drag
phiPart1_loc = np.zeros(ndimz)
averageDrag1_loc = np.zeros(ndimz)
phiPart2_loc = np.zeros(ndimz)
averageDrag2_loc = np.zeros(ndimz)
if debugStress==1:
global vxPartBIS
global phiPartBIS
global averageDragBIS
global dragTermBIS
averageDragBI
phiPartBIS_loc = np.zeros(ndimz)
vxPartBIS_loc = np.zeros(ndimz)
dragTermBIS_loc = np.zeros(ndimz)
#Import the vector of velocity fluctuation associated to each particle in C++ code
VxFluct = addFluidForce.
VzFluct = addFluidForce.
shiftPosition = 1.2*diameterPart #To shift the position in order to avoid to have negative position (not compatible with the volume calculation used later)
## Loop over the file to determine the concentration and the mean velocity
for b in O.bodies:
if isinstance(
z = b.state.
radius = b.shape.radius
Np = int(z/dz) #Layer corresponding to the position of the center of the particle
#Evaluate the drag force undergone by the particle (Dallavalle formulation + Richardson Zaki correction)
uRel = Vector3(0.0,.0,0.0)
if Np<ndimz and Np>=0 : uRel = Vector3(
fDrag = 0.5*pi*
if debugStress==1:
dragTermBIS
phiPartBIS_
vxPartBIS_
#Shift the position to avoid z<0 which induces some problems in the volume calculation. This is done here in order not to change the value of the drag. Evaluate all the parameters after this shift. (Np in particular is reevaluated
z+=shiftPosition
Np = int(z/dz) #new evaluation of Np after the shift. DO NOT REMOVE, IMPORTANT
minZ = int((z-radius)/dz) #Lowest layer occupied by the particle
maxZ = int((z+radius)/dz) #Highest layer occupied by the particle
deltaCenter = z - Np*dz #length between the real center of the particle and the position of the layer in which it is considered to be (Np).
#loop from the bottom to the top layer inside which the particle is contained
numLayer = minZ
while numLayer <= maxZ:
if numLayer>=0 and numLayer<ndimz:
zInf = (numLayer-Np-1)*dz + deltaCenter
zSup = (numLayer-Np)*dz + deltaCenter
if numLayer==minZ: zInf = -radius
if numLayer==maxZ: zSup = radius
#evaluate the volume of the part of the particle contained in the layer considered (the formula results from the analytical resolution of the integral of a layer of sphere in cylindrical coordinate)
V = math.pi*
#Add the quantities to the (not normalized for now) mean particle velocity and concentration
phiPart_
vxPart_
vyPart_
vzPart_
averageDra
if twoSize:
if radius=
elif radius=
#Increment for the next loop
numLayer+=1
#Normalize the weighted velocity/different mean quantities of each layer by the total particle volume in this layer
n = 0
for i in phiPart_loc:
if i: #if non zero, to avoid division by zero
vxPart_loc[n]/=i
vyPart_loc[n]/=i
vzPart_loc[n]/=i
averageDrag_
if twoSize:
if phiPart1_loc[n]:
averageDra
if phiPart2_loc[n]:
averageDra
n += 1
#Normalization of the concentration
phiPart_
phiPart1_
phiPart2_
if debugStress==1:
#Normalization
n = 0
for i in phiPartBIS_
#Normalize the average drag and particle velocity
if i:
averageDrag
vxPartBIS_
n+=1
phiPartBIS_
dragTermBIS_
#Report the value in global variables
vxPartBIS = vxPartBIS_loc
phiPartBIS = phiPartBIS_loc
averageDragBIS = averageDragBIS_loc
dragTermBIS = dragTermBIS_loc
#Resize the vector to remove the effect of the shift previously introduced
phiPart_loc = Resize(
vxPart_loc = Resize(
vyPart_loc = Resize(
vzPart_loc = Resize(
averageDrag_loc = Resize(
phiPart1_loc = Resize(
averageDrag1_loc = Resize(
phiPart2_loc = Resize(
averageDrag2_loc = Resize(
#Impose variables at the bottom to be consistent with the fluid formulation
averageDrag_loc[0] = 0.0
vxPart_loc[0] = 0.0
###Actualize the global variables
phiPart = phiPart_loc
vxPart = vxPart_loc
vyPart = vyPart_loc
vzPart = vzPart_loc
averageDrag = averageDrag_loc
phiPart1 = phiPart1_loc
averageDrag1 = averageDrag1_loc
phiPart2 = phiPart2_loc
averageDrag2 = averageDrag2_loc
#And the one associated to the fluid force application
addFluidForce.
return
###############
#######
###### ######
## Function to resize the vector removing the n first case##
###### ######
def Resize(a,n):
import numpy as np
l = len(a)
b = np.zeros(l)
k = 0
for i in range(n,l):
b[k] = a[i]
k+=1
return b
###############
#######
###### ######
### Save global variables ###
###### ######
#Function to save global variables in a python file which can be re-executed for later
def Save(filePathName, globalVariables):
f = open(filePathNa
f.write('from numpy import *\n')
for i in globalVariables:
f.write(i + ' = '+repr(
f.close()
###############
#######
###### ######
### python Stress field calculation ###
###### ######
def stressFieldCalc
#Initialization
granularTemp_loc = np.zeros(ndimz)
N_loc = np.zeros(ndimz)
stressTensorFi
kineticStressT
for i in range(0,ndimz):
stressTensorF
kineticStress
###
## Dynamical stress tensor part
###
for b in O.bodies:
Np = int((b.state.pos[2] - groundPosition)/dz)
if Np>=0 and Np<ndimz:
vFluct = b.state.vel - Vector3(
stressTensor
kineticStres
granularTemp
N_loc[Np]+=1.0
###
## Love-Weber stress tensor part (contact
###
for Int in O.interactions:
if O.bodies[
Np1 = int((O.
Np2 = int((O.
#Vector joining the two particles (from id2 to id1)
x12 = O.bodies[
#Contact vector of the two particles (defined as applied by id1 on id2)
fContact = Int.phys.
#Remove the artificial effect of the periodic BC if one particle goes to the other side
x12 -= O.cell.
#No reason to have one upon another, so check and define the min and max correpondingly
if Np2==Np1: #If the contact vector is entirely inside the layer, add it directly.
if Np1>=0 and Np1<ndimz:
stressTens
else:
if Np1>Np2: #Particle 1 above 2 (z component)
minZ = Np2
minPosZ = O.bodies[
maxZ = Np1
maxPosZ = O.bodies[
elif Np2>Np1: #Particle 2 above 1 (z component)
minZ = Np1
minPosZ = O.bodies[
maxZ = Np2
maxPosZ = O.bodies[
#Loop over the layers containing the vector connecting the two particles
numLayer = minZ
while numLayer<=maxZ:
if numLayer>=0 and numLayer<ndimz:
deltaZ = dz
if numLayer==minZ:
elif numLayer==maxZ:
branchVec
#Add to stress tensor of the considered layer the part considered
#Increment the layer
numLayer+=1
#Normalization
for n in range(0,
if N_loc[n]>0:
granularTemp
return [stressTensorFi
###############
#######
###DEBUG/COMPARISON WITH getStress
#To obtain exactly the same as getStress, you need to shift groundPosition -> groundPosition - diameterPart + to remove the condition on the dynamics of the particles, to avoid the non contribution of the bottom wall and particles.
#This function might be also useful, it is reproducing exactly getStress in python
def getStressBIS(
stressTensorField = Matrix3(
for Int in O.interactions:
x12 = O.bodies[
x12 -= O.cell.
fContact = Int.phys.
stressTensorF
return stressTensorFie
###############
#######
Revision history for this message
|
#8 |
Hi,
There is a chance that the problem is just not related to yade.
Could you run try this code as a python script and tell us?
B
# testImport.py
import math
import random as rand
import numpy as np
np.set_
import yade.timing
import pylab as pyl
from matplotlib import pyplot as pyp
import matplotlib.gridspec as gridspec
from nsmp1d_
Revision history for this message
|
#9 |
hi I have ran the code as python script and got following error,
# testImport.py
import math
import random as rand
import numpy as np
np.set_
import yade.timing
import pylab as pyl
from matplotlib import pyplot as pyp
import matplotlib.gridspec as gridspec
from nsmp1d_
Revision history for this message
|
#10 |
Which is the error?
ps. "import yade.timing" should not be in the list, sorry.
B
Revision history for this message
|
#11 |
hi the error says,
Welcome to Yade 2017.01a-
TCP python prompt on localhost:9000, auth cookie `kceydu'
XMLRPC info provider on http://
Running script test.py
Traceback (most recent call last):
File "/usr/bin/
execfile(
File "test.py", line 10, in <module>
from nsmp1d_
ImportError: No module named nsmp1d_
Revision history for this message
|
#12 |
Please run it with python, not with Yade.
B
Revision history for this message
|
#13 |
hi, It says,
Traceback (most recent call last):
File "test.py", line 5, in <module>
np.
NameError: name 'numpy' is not defined
Revision history for this message
|
#14 |
Consider spending some time reading through the python tutorial [1].
The line should be corrected to:
np.set_
since we imported numpy as np.
Can you help with this problem?
Provide an answer of your own, or ask Tanvir Hossain for more information if necessary.