#import the ESyS-Particle modules:
from esys.lsm import *
from esys.lsm.util import *

class WallPistonRunnable (Runnable):
   def __init__ (self, 
      sim, 
      wallName,
      wallInteractionName, 
      pressure = 1.0, 
      dirn = Vec3 (0,-1,0), 
      contactArea = 1.0,
      startTime = 10000,
      rampTime = 10000
   ):
      Runnable.__init__(self)

      self.sim = sim
      self.wallName = wallName
      self.wallInteractionName = wallInteractionName
      self.pressure = pressure
      self.dirn = dirn
      self.contactArea = contactArea
      self.startTime = startTime
      self.rampTime = rampTime

      self.nt = 0

      self.dt = self.sim.getTimeStepSize ()
      self.targetForce = self.dirn * (self.pressure * self.contactArea)
      self.initialForce = Vec3(0,0,0)

   def run (self):
      if (self.nt < self.startTime):
         f_ramp = 0.0
      elif ((self.nt >= self.startTime) and (self.nt <= self.rampTime +self.startTime)):
         f_ramp = float(self.nt- self.startTime) / float(self.rampTime)      
      else:
         f_ramp = 1.0

      if (self.nt == self.startTime): 
         self.initialForce = self.sim.getWallForce(self.wallName)
         self.deltaF = self.targetForce - self.initialForce

      if (self.nt >= self.startTime):
         wall_force = (self.deltaF * f_ramp) + self.initialForce
         self.sim.applyForceToWall (self.wallInteractionName, wall_force)

      self.nt = self.nt + 1

GlossyBlue theme adapted by David Gilbert
Powered by PmWiki
www.000webhost.com