# yade-users team mailing list archive

## Re: [Question #695542]: Unstable advection simulaton for gas flow

```Question #695542 on Yade changed:

Zoheir Khademian posted a new comment:
Thanks, Robert

>What does that mean? Is there an error?
There is no error but temperature of spheres goes up to 1e200 in a few timestep. I

>Are you sure? When I use those parameters and decrease the timestep
proportionally to viscosity, the model is stable. Please provide an MWE
[1] ;).

I put the MWE here, which is basically this example [1] but viscosity,
fluid density, and heat capacity are reduced to match those of gas. I
also reduced the time step from 1e-4 to 1e-6. If you run this MWE, you
see that both fluid and solid temperature go up to 1e200 after afew
timesteps.

Sorry, I will open another question

dev/trunk/-/blob/master/examples/ThermalEngine/flowScenario.py

import numpy as np
import shutil
num_spheres=1000# number of spheres
young=1e9

mn,mx=Vector3(0,0,0),Vector3(0.05,0.05,0.05) # corners of the initial
packing

thermalCond = 2. #W/(mK)
heatCap = 710. #J(kg K)
t0 = 333.15 #K

# micro properties
k = 2.0   # 2*k*r
Cp = 710.
rho = 2600.
D = 2.*r
m = 4./3.*np.pi*r**2/rho
# macro diffusivity

identifier = '-flowScenario'

O.materials.append(FrictMat(young=young,poisson=0.5,frictionAngle=0,density=0,label='walls'))
walls=aabbWalls([mn,mx],thickness=0,material='walls')
wallIds=O.bodies.append(walls)

sp = O.bodies.append(ymport.textExt('5cmEdge_1mm.spheres',
'x_y_z_r',color=(0.1,0.1,0.9), material='spheres'))

print('num bodies ', len(O.bodies))

triax=TriaxialStressController(
maxMultiplier=1.+2e4/young,
finalMaxMultiplier=1.+2e3/young,
thickness = 0,
internalCompaction=True,
)

newton=NewtonIntegrator(damping=0.2)
O.engines=[
ForceResetter(),
InteractionLoop(
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()],label="iloop"
),
ThermalEngine,	GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8),
triax,

newton
]

#goal = -1e5
#triax.goal1=triax.goal2=triax.goal3=goal

for b in O.bodies:
if isinstance(b.shape, Sphere):
b.dynamic=False # mechanically static

flow.defTolerance=-1 #0.3
flow.meshUpdateInterval=-1
flow.useSolver=4
flow.permeabilityFactor= 1
flow.viscosity= 0.00013#0.001
flow.bndCondIsPressure=[1,1,0,0,0,0]
flow.bndCondValue=[10,0,0,0,0,0]
flow.thermalEngine=True
flow.debug=False
flow.fluidRho = 0.013#997
flow.fluidCp = 1996#4181.7
flow.getCHOLMODPerfTimings=True
flow.bndCondIsTemperature=[1,0,0,0,0,0]
flow.thermalEngine=True
flow.thermalBndCondValue=[343.15,0,0,0,0,0]
flow.tZero=t0
flow.pZero=0
flow.maxKdivKmean=1
flow.minKdivmean=0.0001;

thermal.debug=False
thermal.fluidConduction=True
thermal.ignoreFictiousConduction=True
thermal.conduction=True
thermal.thermoMech=False
thermal.solidThermoMech = False
thermal.fluidThermoMech = False
thermal.bndCondIsTemperature=[0,0,0,0,0,0]
thermal.thermalBndCondValue=[0,0,0,0,0,0]
thermal.fluidK = 0.6069 #0.650
thermal.fluidConductionAreaFactor=1.
thermal.particleT0 = t0
thermal.particleDensity=2600.
thermal.particleK = thermalCond
thermal.particleCp = heatCap
thermal.useKernMethod=True
#thermal.useHertzMethod=False
timing.reset()

O.dt=0.1e-5#0.1e-3
O.dynDt=False

O.run(1,1)

def bodyByPos(x,y,z):
cBody = O.bodies[1]
cDist = Vector3(100,100,100)
for b in O.bodies:
if isinstance(b.shape, Sphere):
dist = b.state.pos - Vector3(x,y,z)
if np.linalg.norm(dist) < np.linalg.norm(cDist):
cDist = dist
cBody = b
print('found closest body ', cBody.id, ' at ', cBody.state.pos)
return cBody

#bodyOfInterest = bodyByPos(15.998e-3,0.0230911,19.5934e-3)
bodyOfInterest = bodyByPos(0.025,0.025,0.025)

# find 10 bodies along x axis
axis = np.linspace(mn[0], mx[0], num=5)
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[i].state.pos[0]

print("found body of interest at", bodyOfInterest.state.pos)

## a function saving variables
def history():
ftemp1=flow.getPoreTemperature((0.024,0.023,0.02545)),
p=flow.getPorePressure((0.025,0.025,0.025)),
t=O.time,
i = O.iter,
temp1 = axisBodies[0].state.temp,
temp2 = axisBodies[1].state.temp,
temp3 = axisBodies[2].state.temp,
temp4 = axisBodies[3].state.temp,
temp5 = axisBodies[4].state.temp,
bodyOfIntTemp = O.bodies[bodyOfInterest.id].state.temp
)

O.engines=O.engines+[PyRunner(iterPeriod=500,command='history()',label='recorder')]

def endFlux():
if O.time >= 30:
flux = 0
n=utils.porosity()
for i in flow.getBoundaryVel(1):
flux +=i[0]*i[3]/n  # area * velocity / porosity  (dividing by porosity because flow engine is computing the darcy velocity)
massFlux = flux * 997

K = abs(flow.getBoundaryFlux(1))*(flow.viscosity*0.5)/(0.5**2.*(10.-0))
d=8e-3 # sphere diameter
Kc = d**2/180. * (n**3.)/(1.-n)**2

print('Permeability', K, 'kozeny', Kc)
print('outlet flux(with vels only):',massFlux,'compared to CFD = 0.004724 kg/s')
print('sim paused')
O.pause()

O.engines=O.engines+[PyRunner(iterPeriod=10,command='endFlux()')]

plot.plots={'t':(('ftemp1','k-'),('bodyOfIntTemp','r-'))} #
plot.plot()
O.saveTmp()

print("starting thermal sim")
O.run()

--