New question #695331 on Yade:
https://answers.launchpad.net/yade/+question/695331

Dear all, 

I have a  question, if I look into the documentation of Yade DEM the stl import 
function: ymport.stl should work fine with the following commands:

ymport(file, scale = 1.0, shift=Vector3(0,0,0))

I have tried this with the rod penetration example 
https://gitlab.com/yade-dev/trunk/-/tree/master/examples/rod-penetration but it 
was not working. 

I have only added the the scale to the code as attached. Can it be that it is 
connect to the stl file or these commands (scale / shift) does not work for the 
ymport.stl ? 

#!/usr/bin/python
# -*- coding: utf-8 -*-

from __future__ import print_function
from builtins import range
import random
from yade import ymport

## PhysicalParameters 

## Variant of mesh
mesh = 'coarse'
#mesh = 'fine'
#mesh = 'tiny'

## Import geometry 
rod = O.bodies.append(ymport.stl('rod-'+mesh+'.stl',wire=True,scale=1.0,))

# Spheres
sphereRadius = 0.01
nbSpheres = (32,11,32) 
print("Creating %d spheres..."%(nbSpheres[0]*nbSpheres[1]*nbSpheres[2]), end=' 
')
for i in range(nbSpheres[0]):
        for j in range(nbSpheres[1]):
                for k in range(nbSpheres[2]):
                        x = (i*2 - 
nbSpheres[0])*sphereRadius*1.1+sphereRadius*random.uniform(-0.1,0.1)
                        y = -j*sphereRadius*2.2-0.01
                        z = (k*2 - 
nbSpheres[2])*sphereRadius*1.1+sphereRadius*random.uniform(-0.1,0.1)
                        r = random.uniform(sphereRadius,sphereRadius*0.9)
                        fixed = False
                        color=[0.51,0.52,0.4]
                        if (i==0 or i==nbSpheres[0]-1 or j==nbSpheres[1]-1 or 
k==0 or k==nbSpheres[2]-1):
                                fixed = True
                                color=[0.21,0.22,0.1]
                        
O.bodies.append(sphere([x,y,z],r,color=color,fixed=fixed))
print("done\n")

## Estimate time step
#O.dt=PWaveTimeStep()
O.dt=0.0001


## Engines 
O.engines=[
        ## Resets forces and momenta the act on bodies
        ForceResetter(),

        ## Using bounding boxes find possible body collisions.
        InsertionSortCollider([
                Bo1_Sphere_Aabb(),
                Bo1_Facet_Aabb(),
        ]),
        InteractionLoop(
                [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
                [Ip2_FrictMat_FrictMat_FrictPhys()],
                [Law2_ScGeom_FrictPhys_CundallStrack()]
        ),
        ## Apply gravity
        ## Motion equation
        NewtonIntegrator(damping=0.3,gravity=[0,-9.81,0]),
        ## Apply kinematics to rod
        TranslationEngine(ids=rod,translationAxis=[0,-1,0],velocity=0.075),
        ## Save force on rod
        #ForceRecorder(ids=rod,file='force-'+mesh+'.dat',iterPeriod=50),        
]


import sys,time

print("Start simulation: " + mesh)
nbIter=10000

from yade import qt
qt.View()

O.stopAtIter=nbIter
O.run()

#for t in xrange(2):
#       start=time.time();O.run(nbIter);O.wait();finish=time.time() 
#       speed=nbIter/(finish-start); print '%g iter/sec\n'%speed
#print "FINISH"
#quit()



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

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to