yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #22785
Re: [Question #689919]: Accumulation effect of heat over time steps
Question #689919 on Yade changed:
https://answers.launchpad.net/yade/+question/689919
Status: Answered => Open
Chien-Cheng Hung is still having a problem:
Hi Jan,
Thanks again for your reply and suggestion.
I am still learning programming with Python and am also a beginner in
Yade. I am really thankful for these codes which save me plenty of time
and allow me to learn faster. I will try to modify it with my own needs
after getting more familiar with the details.
I tried your code but it turned out the cumulative and temperature
cannot be printed out...
###
class SomeCalculator:
def __init__(self):
self.cumulativeHeatData = dict((a,0) for a in range(2,10))
self.currentHeatData = dict(self.cumulativeHeatData)
self.temperatureData = dict(self.cumulativeHeatData)
def collect(self):
for key,value in self.currentHeatData.items():
self.cumulativeHeatData[key] += value
self.currentHeatData = dict((a,self.getHeatFromOneParticle(a)) for a in range(2,10))
self.computeTemperature()
def getHeatFromOneParticle(self,a):
b = O.bodies[a]
totalHeat = 0
for i in b.intrs():
O.interactions.erase(i.id1,0)
O.interactions.erase(i.id1,1)
O.interactions.erase(0,i.id2)
O.interactions.erase(1,i.id2)
if not i.isReal: continue
penetrationDepth = i.geom.penetrationDepth
radius1 = i.geom.refR1
radius2 = i.geom.refR2
effectiveRadius = (radius1*radius2)/(radius1+radius2)
contactRadius = math.sqrt(penetrationDepth*effectiveRadius)
contactArea = np.pi*(contactRadius**2)
relativeVelocity = i.geom.shearInc.norm()/O.dt
generatedHeat = (i.phys.shearForce.norm()/contactArea)/(i.phys.normalForce.norm()/contactArea) * i.phys.normalForce.norm() * relativeVelocity
totalHeat = totalHeat + generatedHeat
return totalHeat
def computeTemperature(self):
heatCapacity = 900 # [J/kg*K]
density = 2500 # [kg/m3]
for key,cur in self.currentHeatData.items():
cum = self.cumulativeHeatData[key]
for a in range(2,10):
b = O.bodies[a]
temperature = 0.5 * cum * O.dt / heatCapacity / density * (4/3 * np.pi * b.shape.radius**3)
self.temperatureData[key] = temperature
def pprint(self):
print()
print("current heat")
print("============")
for key,value in self.currentHeatData.items():
print(key,value)
print("cumulative heat")
print("==========")
for key,value in self.cumulativeHeatData.items():
print(key,value)
print("temperatures")
print("============")
for key,valve in self.temperatureData.items():
print(key,valve)
###
Is there something wrong with my code?
Cheers,
Chien-Cheng
--
You received this question notification because your team yade-users is
an answer contact for Yade.