Running thermal engine with different initial temperatures
I am trying to re-assign different temperature values after one cycle of thermal engine by "body.state.temp". However, the conduction scheme stops working and newly assigned body temperature does not change by the boundary conditions. Here is the script:
#******
# Copyright (C) 2019 by Robert Caulk *
# <email address hidden> *
# *
# 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. *
#******
#
# Script demonstrating the use of ThermalEngine by comparing conduction
# scheme to analytical solution to Fourier (rod cooling with constant
# boundary conditions). See details in:
#
# Caulk, R., Scholtes, L., Kraczek, M., Chareyre, B. (In Print) A
# pore-scale Thermo-
# Computer Methods in Applied Mechanics and Engineering. Accepted July 2020.
#
from yade import pack
from yade import timing
import numpy as np
import shutil
timeStr = time.strftime(
num_spheres=1000# number of spheres
young=1e6
rad=0.003
mn,mx=Vector3(
thermalCond = 2. #W/(mK)
heatCap = 710. #J(kg K)
t0 = 400. #K
r = rad
k = 2*2.0*r # 2*k*r
Cp = 710.
rho = 2600.
D = 2.*r
m = 4./3.*np.
# macro diffusivity
thermalDiff = 6.*k/(D*
identifier = '-conductionVer
if not os.path.
os.mkdir(
else:
shutil.
os.mkdir(
if not os.path.
os.mkdir(
else:
shutil.
os.mkdir(
shutil.
O.materials.
O.materials.
#walls=
#wallIds=
O.bodies.
print('num bodies ', len(O.bodies))
ThermalEngine = ThermalEngine(
newton=
intRadius = 1
O.engines=[
ForceResetter(),
InsertionSortC
InteractionLoop(
[Ig2_
[Ip2_
[Law2_
),
FlowEngine(
ThermalEngine, GlobalStiffness
#triax,
VTKRecorder(
newton
]
#goal = -1e5
#triax.
#for b in O.bodies:
#if isinstance(b.shape, Sphere):
#b.dynamic=False
# we only need flow engine to detect boundaries, there is no flow computed for this
flow.dead=0
flow.defToleran
flow.meshUpdate
flow.useSolver=4
flow.permeabili
flow.viscosity=10
flow.bndCondIsP
flow.bndCondVal
flow.boundaryUs
flow.thermalEng
flow.debug=False
flow.fluidRho = 1000
flow.fluidCp = 4184
flow.fluidK = 0.650
flow.bndCondIsT
flow.thermalEng
flow.thermalBnd
flow.tZero=t0
flow.pZero=0
thermal.dead=0
thermal.
thermal.
thermal.
thermal.
thermal.
thermal.
thermal.
thermal.
thermal.
thermal.
thermal.
thermal.
thermal.
thermal.
thermal.
timing.reset()
#ThermalEngine.
flow.updateTria
O.dt=1.
O.dynDt=False
O.run(1,1)
flow.dead=1
for b in O.bodies:
if isinstance(
b.state.temp=700.
else:
b.state.temp=100.
#triax.goal2=-11000
def bodyByPos(x,y,z):
cBody = O.bodies[1]
cDist = Vector3(
for b in O.bodies:
if isinstance(b.shape, Sphere):
dist = b.state.pos - Vector3(x,y,z)
if np.linalg.
cDist = dist
cBody = b
print('found closest body ', cBody.id, ' at ', cBody.state.pos)
return cBody
# solution to the heat equation for constant initial condition , BCs=0, and using series for approx
def analyticalHeatS
ns = np.linspace(
solution = 0
for i,n in enumerate(ns):
integral = (-2./L)
solution += integral * np.sin(
return solution
# find 10 bodies along x axis
axis = np.linspace(mn[0], mx[0], num=11)
axisBodies = [None] * len(axis)
axisTrue = np.zeros(len(axis))
for i,x in enumerate(axis):
axisBodies[i] = bodyByPos(x, mx[1]/2, mx[2]/2)
axisTrue[i] = axisBodies[
np.savetxt(
print("Axis length used for analy ", max(axisTrue)
from yade import plot
## a function saving variables
def history():
plot.addData(
t=O.time,
i = O.iter,
temp1 = axisBodies[
temp2 = axisBodies[
temp3 = axisBodies[
temp4 = axisBodies[
temp5 = axisBodies[
temp6 = axisBodies[
temp7 = axisBodies[
temp8 = axisBodies[
temp9 = axisBodies[
temp10 = axisBodies[
temp11 = axisBodies[
)
O.engines=
##make nice animations:
#O.engines=
VTKrec.dead=0
from yade import plot
plot.plots=
#plot.plots=
plot.plot()
O.saveTmp()
O.timingEnabled=1
from yade import timing
print("starting oedometer simulation")
O.run(20000,1)
timing.stats()
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Zoheir Khademian
- Solved:
- Last query:
- Last reply: