From 8b60376576c35249183c3badbcb8375522f6fe5d Mon Sep 17 00:00:00 2001 From: Andreas Holm <60451789+holm10@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:34:34 -0700 Subject: [PATCH] Makes box2 run through - Minimal fixes to make box2 work as expected - Example used Python2, very old... - As such, is not a good representation of how UEDGE or Python should be used Would be wise to replace/update case completely in the future --- pyexamples/box2/box2_in.py | 4 +++- pyexamples/box2/plotcontour.py | 6 ++++-- pyexamples/box2/runcase.py | 21 ++++++++++++--------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/pyexamples/box2/box2_in.py b/pyexamples/box2/box2_in.py index 83bd75b8..8eaa6b4b 100644 --- a/pyexamples/box2/box2_in.py +++ b/pyexamples/box2/box2_in.py @@ -4,6 +4,8 @@ # This is a Python version of the box case from Andreas Holm ########################################################################### +from uedge import bbb, com, grd + #-Geometry bbb.mhdgeo=-1 #-set cartesian geometry @@ -96,7 +98,7 @@ #-Neutral gas propeties -bbb.tfcx=5.;bbb.tfcy=5. #Franck-Condon temperatures +#bbb.tfcx=5.;bbb.tfcy=5. #Franck-Condon temperatures bbb.cngfx=1.;bbb.cngfy=1. #turn-on grad(T_g) flux if =1 bbb.cngflox=1.;bbb.cngfloy=0. #turn-on drift with ions if =1 bbb.cngmom = 1. #ion-gas momentum transfer diff --git a/pyexamples/box2/plotcontour.py b/pyexamples/box2/plotcontour.py index fd273279..559998a5 100644 --- a/pyexamples/box2/plotcontour.py +++ b/pyexamples/box2/plotcontour.py @@ -1,10 +1,12 @@ import matplotlib +import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec +from uedge import bbb, com gs=gridspec.GridSpec(2, 2) plt.figure(10) plt.subplot(gs[0,0]) -CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.te/ev) +CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.te/bbb.ev) plt.clabel(CS, inline=1, fontsize=10) params = {'mathtext.default': 'regular' } plt.rcParams.update(params) @@ -14,7 +16,7 @@ plt.subplot(gs[0,1]) -CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.ti/ev) +CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.ti/bbb.ev) plt.clabel(CS, inline=1, fontsize=10) plt.title('T$\mathregular{_i}$ [ev]') plt.grid(True) diff --git a/pyexamples/box2/runcase.py b/pyexamples/box2/runcase.py index d0a39448..4d77e082 100644 --- a/pyexamples/box2/runcase.py +++ b/pyexamples/box2/runcase.py @@ -9,18 +9,21 @@ import matplotlib.gridspec as gridspec import numpy as np import os +from uedge.uedgeplots import * +from uedge.rundt import rundt #-import some utilities for using OS ###execfile(os.path.join(os.environ['HOME'], 'utils/python/osfun.py')) +def paws(): + programPause = input("Press the key to continue...") ##-how to do this better? #-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") +#execfile(os.environ['PYLIB']+"/plotmesh.py") +#execfile(os.environ['PYLIB']+"/plotcontour.py") +#execfile(os.environ['PYLIB']+"/plotvar.py") +#execfile(os.environ['PYLIB']+"/osfun.py") #execfile("../../plotmesh.py") #execfile("../../pylib/plotvar.py") #execfile("../../pylib/plotr.py") @@ -32,7 +35,7 @@ #-read UEDGE settings -execfile("box2_in.py") +from box2_in import * #-do a quick preliminary run to set all internals @@ -41,7 +44,7 @@ #-show grid plotmesh() -wait = raw_input("PAUSING, PRESS ENTER TO CONTINUE...") +wait = input("PAUSING, PRESS ENTER TO CONTINUE...") #-this should be done in uefacets @@ -66,13 +69,13 @@ bbb.isbcwdt=1 bbb.dtreal = 1e-14; bbb.itermx=30; bbb.exmain() bbb.t_stop=1e0 - bbb.rundt() + rundt() bbb.dtreal=1e20; bbb.isbcwdt=0; bbb.exmain() hdf5_save('mycase.h5') ###execfile('plotcontour.py') - plotcontour() + from plotcontour import * paws()