Skip to content

Commit 6f2acf4

Browse files
committed
Merge branch 'master' of https://github.com/LLNL/UEDGE
2 parents bc34469 + 400d9ca commit 6f2acf4

17 files changed

+661
-0
lines changed

pdfdocs/UEDGE_Primer_v4.pdf

95.4 KB
Binary file not shown.

pdfdocs/empty-file

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

pdfdocs/uedge_man.pdf

538 KB
Binary file not shown.

pyexamples/box2/README

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
In Python do:
2+
execfile("runcase.py")

pyexamples/box2/box2_in.py

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
###########################################################################
2+
# DESCRIPTION OF PROBLEM (box2):
3+
#
4+
# This is a Python version of the box case from Andreas Holm
5+
###########################################################################
6+
7+
8+
#-Geometry
9+
bbb.mhdgeo=-1 #-set cartesian geometry
10+
bbb.isfixlb=2 #left boundary as sym. plane; no flux at cut
11+
12+
grd.radx= 4.e-2 #-outer "radial" wall
13+
grd.rad0=0.0 #-location of 'radial' separ'x for cylinder or slab
14+
grd.radm=-1.e-2 #-minimum "radial" position
15+
16+
grd.za0 = 0. #-poloidal symmetry plane location
17+
grd.zax=3.0 #-poloidal location of divertor plate
18+
grd.zaxpt=2.25 #-poloidal location of x-point
19+
grd.alfyt=-2.0 #radial nonuniformity factor; < 0 => expanding
20+
grd.alfxt=2.76 #poliodal nonuniformity factor; to make smooth
21+
#transition to exp. grid, alfxt should satisfy
22+
#the eqn dzun = (zax-zaxpt+dzun)
23+
# (1-exp(-alfxt/(nx-ixpt2+1))) /
24+
# (1-exp(-alfxt))
25+
#where dzun = (zaxpt-za0)/ixpt2 and
26+
#ixpt2 = ncore(1,2).
27+
28+
grd.btfix = 2. #constant total B-field
29+
grd.bpolfix = .2 #constant poloidal B-field
30+
31+
32+
#-Grid
33+
bbb.gengrid=1; #-Note: for slab the grid is not saved in gridue
34+
bbb.ngrid=1
35+
com.nycore[0]=2
36+
com.nysol[0]=4
37+
com.nxleg[0,1]=3
38+
com.nxcore[0,1]=3
39+
40+
41+
42+
#-Boundary conditions
43+
bbb.isnicore[0]=1 #-same density at all core points
44+
bbb.ncore=1.1e19 #-density on core boundary
45+
bbb.iflcore=1 #if=1, specify core power
46+
bbb.tcoree=25.0 #-used if iflcore=0
47+
bbb.tcorei=25.0 #-used if iflcore=0
48+
bbb.pcoree = 2.5e4 #-used if iflcore=1
49+
bbb.pcorei = 2.5e4 #-used if iflcore=1
50+
51+
bbb.recycp=0.98 #-recycling coef at plates if ndatlb,rb=0
52+
bbb.albdsi=0.99 #-albedos at inner gas source locations
53+
bbb.albdso=0.99 #-albedos at inner gas source locations
54+
55+
bbb.istepfc=0; bbb.istipfc=0 #-priv. flux has zero temp. deriv.
56+
bbb.istewc=0; bbb.istiwc=0 #-wall has zero temp. deriv.
57+
bbb.bcee = 4.; bbb.bcei = 2.5 #-energy transmission coeffs.
58+
bbb.bcen = 0. #-energy transmission coefficint for neutrals
59+
bbb.isupss = 0 #-parallel vel sonic
60+
bbb.isupcore = 0 #-parallel vel =0 on core bndry
61+
62+
63+
64+
#-Transport coefficients
65+
bbb.difni=0.5
66+
bbb.kye=0.7
67+
bbb.kyi=0.7
68+
bbb.travis=1.0
69+
bbb.parvis=1.0
70+
71+
72+
73+
#-Flux limits
74+
bbb.flalfe=0.2
75+
bbb.flalfi=0.2
76+
bbb.flalfgx=1.e0
77+
bbb.flalfgy=1.e0
78+
bbb.flalfgxy=1.e0
79+
bbb.flalfv=0.5
80+
81+
82+
# Finite difference algorithms
83+
bbb.methe=33;bbb.methu=33;bbb.methg=33
84+
bbb.methn=33;bbb.methi=33
85+
86+
87+
#-Solver package
88+
bbb.svrpkg = "nksol" #Newton solver using Krylov method
89+
bbb.mfnksol=-3
90+
bbb.epscon1=0.005
91+
bbb.ftol=1e-10
92+
bbb.premeth = "ilut" #Solution method for precond. Jacobian matrix
93+
bbb.runtim=1e-07
94+
bbb.rlx=0.9
95+
###bbb.del=1.e-8 #-this one causes syntax error!
96+
97+
98+
#-Neutral gas propeties
99+
bbb.tfcx=5.;bbb.tfcy=5. #Franck-Condon temperatures
100+
bbb.cngfx=1.;bbb.cngfy=1. #turn-on grad(T_g) flux if =1
101+
bbb.cngflox=1.;bbb.cngfloy=0. #turn-on drift with ions if =1
102+
bbb.cngmom = 1. #ion-gas momentum transfer
103+
bbb.eion = 5. #birth energy of ions
104+
bbb.ediss = 10. #dissoc. energy lost from elecs (eion=2*ediss)
105+
bbb.isrecmon = 1 #=1 turns on recombination
106+
bbb.cfupcx=1.0 # factor multipling momentum cx
107+
bbb.cfticx=1.0 # factor multipling cx terms in ion energy eqn
108+
109+
110+
111+
#-Parallel neutral momentum equation
112+
bbb.isupgon[0]=1
113+
114+
if (bbb.isupgon[0] == 1):
115+
bbb.isngon=0
116+
com.ngsp=1
117+
com.nhsp=2
118+
###bbb.ziin[com.nhsp-1]=1
119+
bbb.ziin[0]=1
120+
bbb.ziin[1]=0
121+
122+
#-the following are probably default, set them anyway to be sure
123+
bbb.cngmom=0
124+
bbb.cmwall=0
125+
bbb.cngtgx=0
126+
bbb.cngtgy=0
127+
bbb.kxn=0
128+
bbb.kyn=0
129+
130+
131+
#-Currents and potential parameters
132+
bbb.isphion=0
133+
bbb.rsigpl=1.e-8 #anomalous cross-field conductivity
134+
bbb.cfjhf=0. #turn-on heat flow from current (fqp)
135+
bbb.jhswitch=0 #Joule Heating switch
136+
137+
138+
# Atomic physics packages
139+
#com.istabon=10 #DEGAS rates
140+
com.istabon=0 #-analytic rates
141+
142+
143+
#-Misc
144+
bbb.restart=0

pyexamples/box2/empty-file

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

pyexamples/box2/plotcontour.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import matplotlib
2+
import matplotlib.gridspec as gridspec
3+
gs=gridspec.GridSpec(2, 2)
4+
5+
plt.figure(10)
6+
plt.subplot(gs[0,0])
7+
CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.te/ev)
8+
plt.clabel(CS, inline=1, fontsize=10)
9+
params = {'mathtext.default': 'regular' }
10+
plt.rcParams.update(params)
11+
plt.title('T$\mathregular{_e}$ [ev]')
12+
plt.ylabel('R [m]')
13+
plt.grid(True)
14+
15+
16+
plt.subplot(gs[0,1])
17+
CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.ti/ev)
18+
plt.clabel(CS, inline=1, fontsize=10)
19+
plt.title('T$\mathregular{_i}$ [ev]')
20+
plt.grid(True)
21+
22+
23+
plt.subplot(gs[1,0])
24+
CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.ni[:,:,0]/1e20)
25+
plt.clabel(CS, inline=1, fontsize=10)
26+
plt.title('N$\mathregular{_i}$/1e20 [m-3]')
27+
plt.xlabel('Z [m]')
28+
plt.ylabel('R [m]')
29+
plt.grid(True)
30+
31+
32+
plt.subplot(gs[1,1])
33+
CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.up[:,:,0]/1e3)
34+
plt.clabel(CS, inline=1, fontsize=10)
35+
plt.title('U$\mathregular{_p}$/1e3 [m/s]')
36+
plt.xlabel('Z [m]')
37+
plt.grid(True)
38+
39+
40+
plt.show()

pyexamples/box2/runcase.py

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#import uedge as ue
2+
from uedge import *
3+
4+
#import uefacets
5+
import matplotlib.pyplot as plt
6+
import numpy as np
7+
import os
8+
9+
##-how to do this better?
10+
execfile("../../pylib/plotmesh.py")
11+
execfile("../../pylib/plotvar.py")
12+
execfile("../../pylib/plotr.py")
13+
execfile("../../pylib/showrange.py")
14+
execfile("../../pylib/paws.py")
15+
16+
17+
plt.ion()
18+
19+
20+
#-read UEDGE settings
21+
execfile("box2_in.py")
22+
23+
24+
#-do a quick preliminary run to set all internals
25+
bbb.restart=0; bbb.ftol=1e10; bbb.dtreal = 1e-6; bbb.exmain()
26+
27+
28+
#-show grid
29+
plotmesh()
30+
wait = raw_input("PAUSING, PRESS ENTER TO CONTINUE...")
31+
32+
33+
#-this should be done in uefacets
34+
ev=1.6022e-19
35+
36+
37+
if (0):
38+
ue.restore("box2.h5")
39+
bbb.dtreal = 1e20; bbb.exmain()
40+
else:
41+
#-set up some initial state
42+
bbb.ngs=1e14; bbb.ng=1e14
43+
bbb.nis=1e20; bbb.ni=1e20
44+
bbb.ups=0.0; bbb.up=0.0
45+
bbb.tes=ev; bbb.te=ev
46+
bbb.tis=ev; bbb.ti=ev
47+
#
48+
#-Note: if you make a gap here then it will change the logic of if-else!
49+
#
50+
#-run to steady state
51+
bbb.restart=1; bbb.ftol=1e-8;
52+
bbb.isbcwdt=1
53+
bbb.dtreal = 1e-14; bbb.itermx=30; bbb.exmain()
54+
bbb.t_stop=1e0
55+
bbb.rundt()
56+
bbb.dtreal=1e20; bbb.isbcwdt=0; bbb.exmain()
57+
58+
59+
execfile('plotcontour.py')
60+
paws()
61+
62+
63+
##-now refine the solution on a larger grid
64+
#com.nycore[0]=2
65+
#com.nysol[0]=6
66+
#com.nxleg[0,1]=8
67+
#com.nxcore[0,1]=8
68+
#bbb.restart=1; bbb.newgeo=1; bbb.icntnunk=0
69+
#bbb.dtreal = 1e-14; bbb.ftol=1e-10;
70+
#bbb.isbcwdt=1; bbb.itermx=30; bbb.exmain()
71+
#plotmesh()
72+
#paws()
73+
#bbb.t_stop=2e0; bbb.ftol=1e-8; bbb.rundt()
74+
#bbb.dtreal=1e20; bbb.isbcwdt=0; bbb.exmain()
75+
#execfile('plotcontour.py')
76+
#paws()
77+
78+
#==========================================================================#

pyexamples/empty-file

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

pylib/empty-file

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

pylib/paws.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def paws():
2+
programPause = raw_input("Press the <ENTER> key to continue...")

pylib/plotcontour.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
def plotcontour():
2+
3+
#import matplotlib
4+
#import matplotlib.gridspec as gridspec
5+
gs=gridspec.GridSpec(2, 2)
6+
7+
plt.figure(10)
8+
plt.subplot(gs[0,0])
9+
CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.te/ev)
10+
plt.clabel(CS, inline=1, fontsize=10)
11+
params = {'mathtext.default': 'regular' }
12+
plt.rcParams.update(params)
13+
plt.title('T$\mathregular{_e}$ [ev]')
14+
plt.ylabel('R [m]')
15+
plt.grid(True)
16+
17+
18+
plt.subplot(gs[0,1])
19+
CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.ti/ev)
20+
plt.clabel(CS, inline=1, fontsize=10)
21+
plt.title('T$\mathregular{_i}$ [ev]')
22+
plt.grid(True)
23+
24+
25+
plt.subplot(gs[1,0])
26+
CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.ni[:,:,0]/1e20)
27+
plt.clabel(CS, inline=1, fontsize=10)
28+
plt.title('N$\mathregular{_i}$/1e20 [m-3]')
29+
plt.xlabel('Z [m]')
30+
plt.ylabel('R [m]')
31+
plt.grid(True)
32+
33+
34+
plt.subplot(gs[1,1])
35+
CS = plt.contour(com.zm[:,:,0], com.rm[:,:,0], bbb.up[:,:,0]/1e3)
36+
plt.clabel(CS, inline=1, fontsize=10)
37+
plt.title('U$\mathregular{_p}$/1e3 [m/s]')
38+
plt.xlabel('Z [m]')
39+
plt.grid(True)
40+
41+
42+
plt.show()
43+
44+
#====================================================================#

pylib/plotmesh.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Plotting UEDGE computational mesh
2+
#
3+
#-Expects imported modules:
4+
#import matplotlib.pyplot as plt; import numpy as np
5+
#
6+
#
7+
#-Usage:
8+
# execfile("../pylib/plotmesh.py")
9+
# plotmesh()
10+
#
11+
#-Optional arguments:
12+
# iso (True/False) - True for equal aspect ratio
13+
#
14+
#
15+
# First coding: MVU, 17-jul-17
16+
#=========================================================#
17+
18+
def plotmesh(iso=False):
19+
20+
fig,ax = plt.subplots(1)
21+
22+
if (iso):
23+
plt.axes().set_aspect('equal', 'datalim')
24+
else:
25+
plt.axes().set_aspect('auto', 'datalim')
26+
27+
28+
for iy in np.arange(0,com.ny+2):
29+
for ix in np.arange(0,com.nx+2):
30+
plt.plot(com.rm[ix,iy,[1,2,4,3,1]],
31+
com.zm[ix,iy,[1,2,4,3,1]],
32+
color="b")
33+
34+
35+
plt.xlabel('R [m]')
36+
plt.ylabel('Z [m]')
37+
fig.suptitle('UEDGE mesh')
38+
plt.grid(True)
39+
40+
plt.show()
41+
42+
#=========================================================#

pylib/plotr.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Plotting radial profiles of UEDGE data
2+
#
3+
# Usage example:
4+
# plotr(bbb.te/ev, title="Te [eV]")
5+
#
6+
# First coding: MVU, 17-jul-17
7+
#=========================================================#
8+
9+
def plotr(v, title="UEDGE data"):
10+
11+
fig,ax = plt.subplots(1)
12+
13+
plt.plot(com.rm[1,:,0],v[1,:])
14+
plt.plot(com.rm[1,:,0],v[com.nx,:])
15+
16+
plt.plot(com.rm[1,:,0],v[1,:])
17+
plt.plot(com.rm[1,:,0],v[com.nx,:])
18+
19+
plt.xlabel('R [m]')
20+
fig.suptitle(title)
21+
plt.grid(True)
22+
23+
plt.show()
24+
25+
#=========================================================#

0 commit comments

Comments
 (0)