← Back to team overview

yade-users team mailing list archive

Re: [Question #704311]: How can I control the variables in the Partial engine during the simulation?

 

Question #704311 on Yade changed:
https://answers.launchpad.net/yade/+question/704311

JINSUN LEE posted a new comment:
 Dear, Jan.

 Thank you for your kind and prompt reply.

 I tried to make MWE as simple as it is. but it contains local PATH.
 So, please check the line "sys.path.append('/home/jinsun/Dropbox/Yadee/Test')"

 The script consist of 2 sequential script (c.py, c2.py)

You can find the follwoing error after running the final script (c2.py)

The operating system is UBUNTU 22.10

===
% yade c2.py
Welcome to Yade 2022.01a 
Using python version: 3.10.7 (main, Nov 24 2022, 19:45:47) [GCC 12.2.0]
TCP python prompt on localhost:9000, auth cookie `kdscae'
XMLRPC info provider on http://localhost:21000
Running script c2.py
[[ ^L clears screen, ^U kills line. F12 controller, F11 3D view (press "h" in 3D view for help), F10 both, F9 generator, F8 plot. ]]

In [1]: O.engines
Out[1]: 
[<ForceResetter instance at 0x55a9d9360d90>,
 <InsertionSortCollider instance at 0x55a9d943a220>,
 <InteractionLoop instance at 0x55a9d930dff0>,
 <NewtonIntegrator instance at 0x55a9d9120d20>,
 <ServoPIDController instance at 0x55a9d95575a0>,
 <PyRunner instance at 0x55a9d90a7dc0>,
 <RotationEngine instance at 0x55a9d91173d0>]

In [2]: O.engines[6].label
Out[2]: 'ak'

In [3]: ak.ids
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/usr/bin/yade in <module>
----> 1 ak.ids

NameError: name 'ak' is not defined
===

Script c.py
===
from yade import pack, plot

def setGeomVars (): # initialize variables
     width = 0.05
     height = 0.03
     margin = 30
     # Calculate extra length
     dx = width/100/2*margin
     dy = width/100/2*margin
     dz = height/100/2*margin
     saveVars('geoms',loadnow=True,**locals())

setGeomVars ()
from yade.params.geoms import * # load initilized variables

# side pannel
p1s = (-width/2,-width/2-dy,-height/2-dz)
p5s = (-width/2,-width/2-dy,height/2+dz)
p6s = (-width/2,width/2+dy,height/2+dz)
p2s = (-width/2,width/2+dy,-height/2-dz)

side1_1 = utils.facet(vertices=[p1s,p5s,p2s], wire=True, highlight=False) #p1 p5 p2
side1_2 = utils.facet(vertices=[p2s,p5s,p6s], wire=True, highlight=False) #p1 p5 p2
O.bodies.append(side1_1)
O.bodies.append(side1_2)

p4s = (width/2,-width/2-dy,-height/2-dz)
p8s = (width/2,-width/2-dy,height/2+dz)
p7s = (width/2,width/2+dy,height/2+dz)
p3s = (width/2,width/2+dy,-height/2-dz)

side2_1 = utils.facet(vertices=[p4s,p8s,p3s], wire=True, highlight=False) #p1 p5 p2
side2_2 = utils.facet(vertices=[p3s,p8s,p7s], wire=True, highlight=False) #p1 p5 p2
O.bodies.append(side2_1)
O.bodies.append(side2_2)

cp1 = (-width/2,-width/2,2*height/2+dz) #corner point #1
cp2 = (width/2,width/2,3*height/2+dz) #corner point #2
radius_mean = 0.001

sp = pack.SpherePack()
sp.makeCloud(cp1, cp2, rMean=radius_mean, rRelFuzz=0.0, num = 1000)
sp.toSimulation(color=(0,0,1)) # pure blue

O.materials.append(FrictMat(young=20e6, poisson=0.17, density=2000))

wallid1 = range(0,2)


O.engines = [
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
    InteractionLoop(
            [Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],  # collision geometry
            [Ip2_FrictMat_FrictMat_FrictPhys()],  # collision "physics"
            [Law2_ScGeom_FrictPhys_CundallStrack()]  # contact law -- apply forces
    ),
    NewtonIntegrator(gravity=(0, 0, -9.81), damping=0.1),
    ServoPIDController(axis=(0,0,1), ids=wallid1, target=1000, kD=5.0, kI=5.0, kP=5.0, maxVelocity=-0.01, iterPeriod=100, label='ab')
]

def addData():
     for b in O.bodies:
         b.shape.color=scalarOnColorScale(b.state.vel.norm())

O.run(100)

O.engines=O.engines+[PyRunner(command='addData()', iterPeriod=100)]

O.run(100)

O.save("c1.yade")
===

Script c2.py
===
from yade import pack, plot
import sys
import math
sys.path.append('/home/jinsun/Dropbox/Yadee/Test')
O.load("c1.yade")
loadVars('geoms')

from yade.params.geoms import * # load initilized variables

wallid2 = range(2,4)

def addData():
     for b in O.bodies:
         b.shape.color=scalarOnColorScale(b.state.vel.norm())

O.engines=O.engines+[RotationEngine(rotateAroundZero=True, zeroPoint=(0,0,0), rotationAxis=(1, 0, 0), angularVelocity=0.0, ids=wallid2, label="ak")]
===

END OF THE SCRIPT

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.