Error caused by "from builtins import range"
Hi all,
I am running the default oedometer.py file (the example file for PFV) and I get the following error:
Running script examples_
Traceback (most recent call last):
File "/usr/bin/yade", line 182, in runScript
execfile(
File "examples_
from builtins import range
ImportError: No module named builtins
Did anyone else experience this? Any sugeestions. If I go in my .py script and delete the line "from builtins import range", it does not show any error and it seems to work. Any one facing the same issue?
Thank you so much for your help!
CODE:
# -*- coding: utf-8 -*-
#******
# Copyright (C) 2010 by Bruno Chareyre *
# bruno.chareyre_
# *
# This program is free software; it is licensed under the terms of the *
# GNU General Public License v2 or later. See file LICENSE for details. *
#******
## Example script for using the DEM-PFV coupling introduced with E. Catalano, as reported in:
## * [Chareyre2012a] Chareyre, B., Cortis, A., Catalano, E., Barthélemy, E. (2012), Pore-scale modeling of viscous flow and induced forces in dense sphere packings. Transport in Porous Media (92), pages 473-493. DOI 10.1007/
## http://
## * [Catalano2014a] Catalano, E., Chareyre, B., Barthélémy, E. (2013), Pore-scale modeling of fluid-particles interaction and emerging poromechanical effects. International Journal for Numerical and Analytical Methods in Geomechanics. DOI 10.1002/nag.2198
## http://
## Also used in:
## * Tong et al.2012 (http://
## * Sari et al 2011 (http://
## The DEM-PFV is applied here to 1D consolidation (oedometer test). The example includes the determination of oedometer modulus Ee and permeability K.
## The 1D consolidation is simulated as a coupled problem and the analytical solution corresponding to the abovementionned Ee and K is used for comparison.
## See triax-tutorial/
## ______________ First section, similar to triax-tutorial/
from __future__ import print_function
from builtins import range
from yade import pack
num_spheres=1000# number of spheres
young=1e6
compFricDegree = 3 # initial contact friction during the confining phase
finalFricDegree = 30 # contact friction during the deviatoric loading
mn,mx=Vector3(
O.materials.
O.materials.
walls=aabbWalls
wallIds=
sp=pack.
sp.makeCloud(
sp.toSimulation
triax=TriaxialS
maxMultiplier=
finalMaxMultip
thickness = 0,
stressMask = 7,
max_vel = 0.005,
internalCompac
)
newton=
O.engines=[
ForceResetter(),
InsertionSortC
InteractionLoop(
[Ig2_
[Ip2_
[Law2_
),
FlowEngine(
GlobalStiffnes
triax,
newton
]
triax.goal1=
while 1:
O.run(1000, True)
unb=unbalance
if unb<0.001 and abs(-10000-
break
setContactFrict
## ______________ Oedometer section _________________
#A. Check bulk modulus of the dry material from load/unload cycles
triax.stressMask=2
triax.goal1=
triax.internalC
triax.wall_
#load
triax.goal2=-11000; O.run(2000,1)
#unload
triax.goal2=-10000; O.run(2000,1)
#load
triax.goal2=-11000; O.run(2000,1)
e22=triax.strain[1]
#unload
triax.goal2=-10000; O.run(2000,1)
e22=e22-
modulus = 1000./abs(e22)
#B. Activate flow engine and set boundary conditions in order to get permeability
flow.dead=0
flow.defToleran
flow.meshUpdate
flow.useSolver=3
flow.permeabili
flow.viscosity=10
flow.bndCondIsP
flow.bndCondVal
flow.boundaryUs
O.dt=0.1e-3
O.dynDt=False
O.run(1,1)
Qin = flow.getBoundar
Qout = flow.getBoundar
permeability = abs(Qin)/1.e-4 #size is one, we compute
print("Qin=",Qin," Qout=",Qout," permeability=
#C. now the oedometer test, drained at the top, impermeable at the bottom plate
flow.bndCondIsP
flow.bndCondVal
flow.updateTria
newton.damping=0
#we want the theoretical value from Terzaghi's solution
#keep in mind that we are not in an homogeneous material and the small strain
#assumption is not verified => we don't expect perfect match
#there can be also an overshoot of pressure in the very beginning due to dynamic effects
Cv=permeability
zeroTime=O.time
zeroe22 = - triax.strain[1]
dryFraction=0.05 #the top layer is affected by drainage on a certain depth, we account for it here
drye22 = 1000/modulus*
wetHeight=
def consolidation(Tv): #see your soil mechanics handbook...
U=1
for k in range(50):
M=pi/2*(2*k+1)
U=U-2/
return U
triax.goal2=-11000
from yade import plot
## a function saving variables
def history():
plot.addData(
#plot.
O.engines=
##make nice animations:
#O.engines=
from yade import plot
plot.plots=
plot.plot()
O.saveTmp()
O.timingEnabled=1
from yade import timing
print("starting oedometer simulation")
O.run(200,1)
timing.stats()
print("\nPress ▶ (the start button) to see graph.\n")
## Make more steps to see the convergence to the stationnary solution
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Najm
- Solved:
- 2020-04-09
- Last query:
- 2020-04-09
- Last reply:
- 2020-04-02
Chareyre (bruno-chareyre-9) said : | #1 |
Hi, I ran the pasted script with Yade 2019-04-
Found no issue.
B
On Thu, 2 Apr 2020 at 21:58, mrhappy <email address hidden>
wrote:
> New question #689671 on Yade:
> https:/
>
> Hi all,
>
> I am running the default oedometer.py file (the example file for PFV) and
> I get the following error:
>
> Running script examples_
> Traceback (most recent call last):
> File "/usr/bin/yade", line 182, in runScript
> execfile(
> File "examples_
> from builtins import range
> ImportError: No module named builtins
>
> Did anyone else experience this? Any sugeestions. If I go in my .py
> script and delete the line "from builtins import range", it does not show
> any error and it seems to work. Any one facing the same issue?
>
> Thank you so much for your help!
>
> CODE:
>
> # -*- coding: utf-8 -*-
> #******
> # Copyright (C) 2010 by Bruno Chareyre *
> # bruno.chareyre_
> # *
> # This program is free software; it is licensed under the terms of the *
> # GNU General Public License v2 or later. See file LICENSE for details. *
> #******
>
> ## Example script for using the DEM-PFV coupling introduced with E.
> Catalano, as reported in:
> ## * [Chareyre2012a] Chareyre, B., Cortis, A., Catalano, E., Barthélemy,
> E. (2012), Pore-scale modeling of viscous flow and induced forces in dense
> sphere packings. Transport in Porous Media (92), pages 473-493. DOI
> 10.1007/
> ## http://
> ## * [Catalano2014a] Catalano, E., Chareyre, B., Barthélémy, E. (2013),
> Pore-scale modeling of fluid-particles interaction and emerging
> poromechanical effects. International Journal for Numerical and Analytical
> Methods in Geomechanics. DOI 10.1002/nag.2198
> ## http://
> ## Also used in:
> ## * Tong et al.2012 (http://
> ## * Sari et al 2011 (
> http://
> )
>
>
> ## The DEM-PFV is applied here to 1D consolidation (oedometer test). The
> example includes the determination of oedometer modulus Ee and permeability
> K.
> ## The 1D consolidation is simulated as a coupled problem and the
> analytical solution corresponding to the abovementionned Ee and K is used
> for comparison.
> ## See triax-tutorial/
> the packing generation procedure.
>
> ## ______________ First section, similar to
> triax-tutorial/
> from __future__ import print_function
> from builtins import range
> from yade import pack
>
> num_spheres=1000# number of spheres
> young=1e6
> compFricDegree = 3 # initial contact friction during the confining phase
> finalFricDegree = 30 # contact friction during the deviatoric loading
> mn,mx=Vector3(
>
>
> O.materials.
>
> O.materials.
> walls=aabbWalls
> wallIds=
>
> sp=pack.
> sp.makeCloud(
> the "random" generation always the same
> sp.toSimulation
>
> triax=TriaxialS
> maxMultiplier=
> finalMaxMultipl
> growth)
> thickness = 0,
> stressMask = 7,
> max_vel = 0.005,
> internalCompact
> generated by growing particles
> )
>
> newton=
>
> O.engines=[
> ForceResetter(),
> InsertionSortCo
> InteractionLoop(
> [Ig2_Sphere_
> [Ip2_FrictMat_
> [Law2_ScGeom_
> ),
> FlowEngine(
> the moment, see 2nd section
>
> GlobalStiffness
> triax,
> newton
> ]
>
> triax.goal1=
>
> while 1:
> O.run(1000, True)
> unb=unbalancedF
> if unb<0.001 and abs(-10000-
> break
>
> setContactFrict
>
> ## ______________ Oedometer section _________________
>
> #A. Check bulk modulus of the dry material from load/unload cycles
> triax.stressMask=2
> triax.goal1=
>
> triax.internalC
> triax.wall_
> #load
> triax.goal2=-11000; O.run(2000,1)
> #unload
> triax.goal2=-10000; O.run(2000,1)
> #load
> triax.goal2=-11000; O.run(2000,1)
> e22=triax.strain[1]
> #unload
> triax.goal2=-10000; O.run(2000,1)
>
> e22=e22-
> modulus = 1000./abs(e22)
>
> #B. Activate flow engine and set boundary conditions in order to get
> permeability
> flow.dead=0
> flow.defToleran
> flow.meshUpdate
> flow.useSolver=3
> flow.permeabili
> flow.viscosity=10
> flow.bndCondIsP
> flow.bndCondVal
> flow.boundaryUs
> O.dt=0.1e-3
> O.dynDt=False
>
> O.run(1,1)
> Qin = flow.getBoundar
> Qout = flow.getBoundar
> permeability = abs(Qin)/1.e-4 #size is one, we compute
> print("Qin=",Qin," Qout=",Qout," permeability=
>
> #C. now the oedometer test, drained at the top, impermeable at the bottom
> plate
> flow.bndCondIsP
> flow.bndCondVal
> flow.updateTria
> immediately
> newton.damping=0
>
> #we want the theoretical value from Terzaghi's solution
> #keep in mind that we are not in an homogeneous material and the small
> strain
> #assumption is not verified => we don't expect perfect match
> #there can be also an overshoot of pressure in the very beginning due to
> dynamic effects
> Cv=permeability
> zeroTime=O.time
> zeroe22 = - triax.strain[1]
> dryFraction=0.05 #the top layer is affected by drainage on a certain
> depth, we account for it here
> drye22 = 1000/modulus*
> wetHeight=
>
> def consolidation(Tv): #see your soil mechanics handbook...
> U=1
> for k in range(50):
> M=pi/2*(2*k+1)
> U=U-2/M*
> return U
>
> triax.goal2=-11000
>
>
>
> from yade import plot
>
> ## a function saving variables
> def history():
>
> plot.addData(
>
> #plot.addData(
>
>
> O.engines=
> ##make nice animations:
> #O.engines=
>
> from yade import plot
> plot.plots=
> plot.plot()
> O.saveTmp()
> O.timingEnabled=1
> from yade import timing
> print("starting oedometer simulation")
> O.run(200,1)
> timing.stats()
>
> print("\nPress ▶ (the start button) to see graph.\n")
>
> ## Make more steps to see the convergence to the stationnary solution
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
>
--
--
_______________
Bruno Chareyre
Associate Professor
ENSE³ - Grenoble INP
Lab. 3SR
BP 53
38041 Grenoble cedex 9
Tél : +33 4 56 52 86 21
________________
Email too brief?
Here's why: email charter
<https:/
Najm (mrhappy) said : | #2 |
Hi,
Thank you for your message. I am currentlty using Yade 2018.02b . Should I upgrade it?
I don't know. Are you using an example script coming with the same version of yade?
B
Najm (mrhappy) said : | #4 |
I downloaded the latest on from [1] yade-2020.
Thank you for your help!