Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 29 additions & 53 deletions pyexamples/d3dHsm/runcase.py
Original file line number Diff line number Diff line change
@@ -1,70 +1,46 @@
#-import uedge
from uedge import *
# import uedge
from uedge import bbb, rundt, uedgeplots

#-import hdf5 routines
from uedge.hdf5 import *
# read UEDGE settings
exec(open("rd_d3dHsm_in.py").read())

#-import graphics, math, etc.
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import numpy as np
import os

#-import some utilities for using OS
###execfile(os.path.join(os.environ['HOME'], 'utils/python/osfun.py'))


#-in .bashrc: "export PYLIB=/home/umansky1/PyUEDGE/uedge/pylib"
execfile(os.environ['PYLIB']+"/plotmesh.py")
execfile(os.environ['PYLIB']+"/plotcontour.py")
execfile(os.environ['PYLIB']+"/plotvar.py")
execfile(os.environ['PYLIB']+"/paws.py")
execfile(os.environ['PYLIB']+"/osfun.py")

plt.ion()


#-read UEDGE settings
execfile("rd_d3dHsm_in.py")


#-do a quick preliminary run to set all internals
# do a quick preliminary run to set all internals
bbb.restart=0; bbb.ftol=1e10; bbb.dtreal = 1e-6; bbb.exmain()

# Plot the mesh
uedgeplots.plotmesh()

#-show grid
plotmesh(iso=1)
wait = raw_input("PAUSING, PRESS ENTER TO CONTINUE...")


#-run to steady state
# Take a small time step
bbb.restart=1; bbb.ftol=1e-8;
bbb.isbcwdt=1
bbb.dtreal = 1e-14; bbb.itermx=30; bbb.exmain()
bbb.t_stop=1e0
bbb.rundt()
bbb.dtreal=1e20; bbb.isbcwdt=0; bbb.exmain()


#-show some results
plotvar(bbb.te/bbb.ev)
# run to steady state
case = rundt.UeRun()
case.converge(savedir=".")

#-export the solution in hdf5 file
hdf5_save('mycase.h5')
# Check that we've really reached steady state
bbb.dtreal=1e20; bbb.isbcwdt=0; bbb.exmain()

#-can be imported with this command
#hdf5_restore('mycase.h5')
# export the solution in hdf5 file
case.save_intermediate(".", "d3dHsm")

# Plot the ion density
uedgeplots.plotmeshval(bbb.ni, title='Ion density', units=r'm$^-3$')

###-refine the grid, interpolate to new grid, and restart:
#com.nxleg[0,0]=20; bbb.newgeo=1; bbb.icntnunk=0
#bbb.dtreal = 1e-14; bbb.isbcwdt=1; bbb.itermx=30; bbb.exmain()
com.nxleg[0,0]=20; bbb.newgeo=1; bbb.icntnunk=0
bbb.dtreal = 1e-14; bbb.isbcwdt=1; bbb.itermx=30; bbb.exmain()

# Plot the new mesh
uedgeplots.plotmesh()

###-time advance by another second
#bbb.t_stop=2e0; bbb.rundt()
# Converge to steady state
case.converge(savedir=".")

bbb.dtreal=1e20; bbb.isbcwdt=0; bbb.exmain()

###-now to steady state (infinite time)
#bbb.dtreal=1e20; bbb.isbcwdt=0; bbb.exmain()
# Plot electron temperature
uedgeplots.plotmeshval(bbb.te/bbb.ev, title='Electron temperature', units='eV')

###-show some results
#plotvar(bbb.te/bbb.ev)
input("Wait for figures to appear, then press return to exit.")