def Emol(n0g=1e17, ngbackg=1e10, kelighg=5e-16, kelighi=5e-16, cngfx=1, cngfy=1, cfcvtg=1, cftgcond=1, isngcore=0, albedoc=0.5, ngcore=1e12, istgcore=2, tgcore=100, tgwall=4e-2, ismolcrm=1): igh2 = activate_mol() bbb.istgcon[igh2] = -1. # Don't reset tg[,,2] using istgcon # Set the energy boundary conditions energy_bc_mol(igh2, isngcore, albedoc, ngcore, istgcore, tgcore, tgwall) # Set parameters common to all mol models common_mol(igh2, n0g, ngbackg, kelighg, kelighi, cngfx, cngfy, cfcvtg, cftgcond, ismolcrm) """---------------------------------------------------------------------------------------------------- ALLOCATE MOLECULAR ARRAYS ----------------------------------------------------------------------------------------------------""" if bbb.pyrestart_file[0].decode('UTF-8') != 'read': bbb.allocate()
def constantTm(Tm, n0g=1e17, ngbackg=1e11, kelighg=5e-16, kelighi=5e-16, cngfx=0, cngfy=0, cfcvtg=1, cftgcond=1, ismolcrm=1): """==================================================================================================== MOLECULAR HYDROGEN SETUP FOR MOLECULES WITH SPATIALLY CONSTANT TEMPERAUR ====================================================================================================""" igh2 = activate_mol() bbb.istgcon[igh2] = 1. # Don't reset tg[,,2] using istgcon bbb.tgas[1] = Tm # Set parameters common to all mol models common_mol(igh2, n0g, ngbackg, kelighg, kelighi, cngfx, cngfy, cfcvtg, cftgcond, ismolcrm) """---------------------------------------------------------------------------------------------------- ALLOCATE MOLECULAR ARRAYS ----------------------------------------------------------------------------------------------------""" if bbb.pyrestart_file[0].decode('UTF-8') != 'read': bbb.allocate()
def reset(): ''' File that resets UEDGE to the default setup ''' import h5py from numpy import array from uedge import com,aph,api,bbb,flx,grd,svr,wdf hf=h5py.File('/home/holm10/uedge/uescripts/reset.hdf5') # Set species indices com.nhsp=hf['com']['nhsp'][()] com.nhgsp=hf['com']['nhgsp'][()] com.ngsp=hf['com']['ngsp'][()] com.nzsp=hf['com']['nzsp'][()] com.nxleg=hf['com']['nxleg'][()] com.nxcore=hf['com']['nxcore'][()] com.nycore=hf['com']['nycore'][()] com.nysol=hf['com']['nysol'][()] bbb.mhdgeo=hf['bbb']['mhdgeo'][()] aph.mpe=hf['aph']['mpe'][()] aph.mpd=hf['aph']['mpd'][()] aph.mpr=hf['aph']['mpr'][()] bbb.igspsori=hf['bbb']['igspsori'][()] bbb.igspsoro=hf['bbb']['igspsoro'][()] bbb.isimpon=hf['bbb']['isimpon'][()] # Allocate the correct size of all arrays bbb.allocate() bbb.ishymol=0 # Restore all values #bbb.issfon=0;bbb.ftol=1e20;exmain();bbb.issfon=1;bbb.ftol=1e-8 bbb.gchange('Impurity_source',0) for p in hf.keys(): for v in hf[p].keys(): if hf[p][v].dtype in ['int32','int64','float32','float64']: if v=='del': continue if len(hf[p][v].shape)==0: if array(hf[p][v]).max()==0: exec('{}.{}=0'.format(p,v)) elif array(hf[p][v]).max()==1: exec('{}.{}=1'.format(p,v)) elif array(hf[p][v]).max()==300: exec('{}.{}=300'.format(p,v)) else: a=hf[p][v][()] exec('{}.{}=a'.format(p,v)) #exec('{}.{}=hf[{}][{}][()]'.format(p,v,p,v)) else: if array(hf[p][v]).max()==0: exec('{}.{}=0'.format(p,v)) elif array(hf[p][v]).max()==1: exec('{}.{}=1'.format(p,v)) elif array(hf[p][v]).max()==300: exec('{}.{}=300'.format(p,v)) else: a=hf[p][v][()] exec('{}.{}=a'.format(p,v)) #exec('{}.{}=array(hf[{}][{}])'.format(p,v,p,v)) # Restore all values bbb.issfon=0;bbb.ftol=1e20;exmain();bbb.issfon=1;bbb.ftol=1e-8
def wall_source(nzsor=1): ''' Defines an impurity wall source ''' # TODO: Needs fixing api.nzsor=nzsor # number of wall source zones for impurity bbb.allocate() # Allocate wall source arrays api.iszsorlb=0 # measure from left boundary api.wimpi=1000. # width of impurity source zone in PF api.impsori[0]=0. # PF wall source strength [A] api.wimpo=1000. # width of impurity source zone on outer wall api.impsoro[0]=0. # outer wall source strength [A] bbb.ivolcur=0.0 # volume source [A] for EACH charge species bbb.zwni=1000. # width for volume source bbb.rwni=1000. # width for volume source
def molbox(T, ismolcrm=1, ngbackg=1e10, istgon=0): # Add molecules density & temp bbb.ismolcrm = ismolcrm igh2 = activate_mol() bbb.isngon[igh2] = 1 bbb.istgcon[igh2] = -1 if bbb.pyrestart_file[0].decode('UTF-8') != 'read': bbb.allocate() bbb.tgas = 0.02 bbb.tgwall = 0.04 bbb.istgon = 0 bbb.istgon[1] = istgon bbb.tgs[:, :, igh2] = T * bbb.ev bbb.ngbackg[igh2] = ngbackg #floor level where background neut source on
def static_plasma(n, T, aphdir="../../rates/aph", isrecmon=1): ''' Static background plasma ''' aph.aphdir = aphdir bbb.isnion[0] = 0 bbb.isteon = 0 bbb.istion = 0 bbb.isupon = 0 bbb.tes = T * bbb.ev bbb.tis = T * bbb.ev bbb.nis[:, :, 0] = n bbb.ups = 0 # Currents and potential parameters bbb.isphion = 0 # Atomic physics packages com.istabon = 10 #Stotler's '9 # Neutral atom properties bbb.eion = 2.3 #birth energy of ions bbb.ediss = 4.6 #dissoc. energy lost from elecs [bbb.eion=2*bbb.ediss] bbb.isrecmon = isrecmon #=1 turns on recombination bbb.ngbackg[0] = 1.5e8 #floor level where background neut source on bbb.bcee = 4. bbb.bcei = 2.5 #energy transmission coeffs. bbb.isupss = 1 #parallel vel sonic # Parallel neutral momentum equation bbb.isupgon[0] = 1 bbb.isngon[0] = 0 com.nhsp = 2 com.ngsp = 1 bbb.ziin[com.nhsp - 1] = 0 bbb.recycm = -10. # -10 gives dup/com.dx=0 for atoms at plate5 APS rates bbb.methg = 33 if bbb.pyrestart_file[0].decode('UTF-8') != 'read': bbb.allocate()
def powerdens_core(pcoree, pcorei, ncore, aphpath='.', lyni=[0.05, 0.05], nwomin=1e15, lyte=[0.05, 0.05], lyti=[0.05, 0.05], nwimin=1e16, isplflxl=1, ngbackg=1e10, cngflox=1, cngfloy=1, isngcore=1, albedoc=0.5, isupcore=1, xstscal=0.02, ngscal=1, xgscal=0.01, cfloxiplt=1): """ Plasma setup with power and density BC at core plasma_Pcore_ncore(pcoree,pcorei,ncore,aphpath) Function setting up the UEDGE plasma with core-flux power boundary conditions for ions and electrons and constant core boundary plasma density boundary condition. Keyword parameters: pcoree - electron power crossing the core boundary pcorei - ion power crossing the core boundary ncore - plasma density at the core boundary aphpath - path to hydrogenic rate filestoms """ # Set path to rate data aph.aphdir = aphpath # Hydrogen rates # Initalize arrays com.nhsp = 2 # N.o. hydrogenic species com.ngsp = 1 # N.o. hydrogenic gaseous species ''' Charged species setup ''' bbb.minu[0] = 2 # H+ mass in AMU bbb.ziin[0] = 1 # H+ bbb.znuclin[0] = 1 # H+ nuclear charge # Scale factors #- - - - - - - - - - - bbb.cngtgx = 0. # X-flux coefficient for gaseous component i in ion energy equation bbb.cngtgy = 0. # Y-flux coefficient for gaseous component i in ion energy equation corepower(pcoree, pcorei) # Set power BC for ions at core bound coremomentum(isupcore) # Set neumann momentum BC for plasma at core bound coredens(ncore) # Set dirichlet BC for plasma at core bound wall_BC_scalelength(lyni=lyni, nwomin=nwomin, lyte=lyte, lyti=lyti, nwimin=nwimin, isplflxl=isplflxl) # Set gradient scal-length wall BCs ''' Atom model setup ''' inertial_atoms(ngbackg=ngbackg, cngflox=cngflox, cngfloy=cngfloy, isngcore=isngcore, albedoc=albedoc, isupcore=isupcore, xstscal=xstscal, ngscal=ngscal, xgscal=xgscal, cfloxiplt=cfloxiplt) # Activate intertial atoms ''' Rate model setup ''' Stotler_loglog() # Use Stotler log-log rate file ''' Allocate plasma arrays ''' if bbb.pyrestart_file[0].decode('UTF-8') != 'read': bbb.allocate()
def carbon_forcebalance( apipath='.', isnicore=3, ncore=4e15, curcore=0, isupcore=1, isnwcono=3, nwomin=1e7, isnwconi=3, nwimin=1e7, tgwall=4e-2, isbohmms=0, n0=1e17, n0g=1e18, nzbackg=1e10, inzb=2,ngbackg=1e10, ismctab=2, mcfilename='C_rates.adas', isrtndep=1, rcxighg=0, iscxfit=2, kelighi=5e-16, kelighg=5e-16, isch_sput=7, fchemygwi=1, fchemygwo=1, fchemylb=1, fchemyrb=1, isph_sput=3, fphysylb=1, fphysyrb=1, isi_sputw=2, isi_sputpf=2, t_wall=300, t_plat=300,isngcore=0,ngcore=1e15 ): """===================================================================================================== CARBON SETUP =====================================================================================================""" # Turn impurity ions on bbb.isimpon=6 # Switch for activating impurities #=0: no impurities #=2: fixed-fraction model #=5: Hirshman's reduced-ion model #=6: force-balance model or nusp_imp > 0; see also isofric for full-Z drag term #=7: for simultaneous fixed-fraction and multi-charge-state (isimpon=6) models api.apidir=apipath # Impurity rates # IMPURITY SETUP #- - - - - - - - # Helper indices Ccs=6 # Carbon charge states zind=com.ngsp-bbb.ishymol-1 # Carbon impurity species index ingc=com.ngsp iicl=com.nhsp # Determine the lower ion index for carbon for z in com.nzsp: iicl+=z iicu=iicl+Ccs # Allocate space com.ngsp+=1 # 1 gaseous C species com.nzsp[zind]=Ccs # Number of impurity species for gas species species+1 # Determines nisp (nisp=nhsp+sum(nzsp)) and allocates arrays # Turn impurity gas on #- - - - - - - - - - - #bbb.istgcon[com.ngsp]=0 # Impurity gas temperature: tg=(1-istgcon)*rtg2ti*ti+istgcon*tgas*ev # Impurity species parameters #- - - - - - - - - - - - - - - bbb.ziin[iicl:iicu]=range(1,Ccs+1) # Impurity charge states bbb.minu[iicl:iicu]=12 # Atomic mass unit species mass bbb.znuclin[iicl:iicu]=6 # Nuclear charge of impurities # Core BC #----------------------------------------------------------------------------------------------- bbb.isnicore[iicl:iicu]=isnicore # Core impurity ion BC model #=0: flux = curcore/sy locally in ix #=1: uniform, fixed density, ncore #=2: flux & ni over range #=3: icur=curcore-recycc*fngy, const ni #=4: impur. source terms (impur only) #=5: d(ni)/dy=-ni/lynicore at midp & ni constant poloidall if 1 in bbb.isnicore[iicl:iicu]: # Constant imputiry dens on core vboundary bbb.ncore[iicl:iicu]=ncore # Core boundary density if 3 in bbb.isnicore[iicl:iicu]: # Core BC set by fluxes bbb.curcore[iicl:iicu]=curcore # Constant flux contribution over core BC bbb.isupcore[iicl:iicu]=isupcore # Velocity BC: #=0; Dirichlet BC: up=upcore #=1; Neumann BC: d(up)/dy=0 #=2 sets d^2(up)/dy^2 = 0 #=3 sets poloidal velocity (uu) = 0 #=4 sets tor. ang mom flux = lzflux & n*uz/R=const #=5 sets ave tor vel = utorave & n*uz/R=const bbb.isngcore[ingc]=isngcore # Neutral gas density BC at core # 0 - set loc flux= -(1-albedoc)*ng*vtg/4 #=1, set uniform, fixed density, ngcore #=2, not available #=3, extrapolation, but limited #=anything else, set zero deriv which was #prev default inert hy # anything else same as =0 if bbb.isngcore[ingc]==1: bbb.ngcore[ingc]=1e9 # Set Uniform density if BC requested # Carbon wall BC #----------------------------------------------------------------------------------------------- # Outer wall - ION #- - - - - - bbb.isnwcono[iicl:iicu]=isnwcono# Outer wall BC: #=0, old case; if ifluxni=0, dn/dy=0; if ifluxni=1, fniy=0 (default) #=1, fixed density to nwallo(ix) array #=2, extrapolation B.C. #=3, approx gradient scale length, limited by nwomin if 3 in bbb.isnwcono[iicl:iicu]: # Grad scale length BC: same as for plasma bbb.nwomin[iicl:iicu]=nwomin # Minimum outer wall density # PFR wall - ION #- - - - - bbb.isnwconi[iicl:iicu]=isnwconi# PFR wall BC: as above if 3 in bbb.isnwconi[iicl:iicu]: # Grad scale length BC: same as for plasma bbb.nwimin[iicl:iicu]=nwimin # Minimum PFR wall density # Gas wall BC #- - - - - - bbb.tgwall[ingc] = tgwall # Wall gas temperature when BC used, carbon # Impurity plate BC:s #----------------------------------------------------------------------------------------------- bbb.isbohmms=isbohmms #0=single-species Bohm condition (H+) #1=multi-species Bohm condition (all ions) # Normalization and background #----------------------------------------------------------------------------------------------- bbb.n0[iicl:iicu]=n0 # Global impurity ion density normalization bbb.n0g[ingc]=n0g # Global impurity gas density normalization bbb.nzbackg=nzbackg # Background impurity ion density bbb.inzb=inzb # Impurity floor scaling (nzbackg/ni)^inzb bbb.ngbackg[ingc]=ngbackg # Impurity gas background density # Impurity rates #----------------------------------------------------------------------------------------------- # Setup rate model #- - - - - - - - - bbb.ismctab=ismctab # Define data to be used for multi-charge-state rates #=1: tables originally generated by R. Campbell for D. Knoll, # data file name is specified by inelmc=.... # corresponding rate evaluation routines are imprates and radimpmc. #=2: tables generated by code from B. Braams, # data file name is specified by mcfilename=..., # corresponding rate evaluation routines are mcrates and radmc if bbb.ismctab==2: # Braams tables com.mcfilename[0]=mcfilename # Rate data to be used com.isrtndep=isrtndep # Are table lookup parameters density dependent # Check compability with hydrogen if istabon=16 # CX #- - - bbb.rcxighg[ingc]=rcxighg # Turn off imp0 + H+ --> imp+ + H+ com.iscxfit=iscxfit # C-ion + H0 CX model: #=0: analytic forms in Braams' rate package #=1: polynomial fit to C.F. Maggi curves (1997) #=2: same as =1, except Z=1 has lower rate from Pigarov # Scattering #- - - - - - bbb.kelighi[ingc] = kelighi # Elastic collision coefficient with H+ bbb.kelighg[ingc] = kelighg # Elastic collision coefficient with H0 # Impurity sputtering #----------------------------------------------------------------------------------------------- # Chemical #- - - - - bbb.isch_sput[ingc]=isch_sput # Chemical sputtering model #=0: Old #=5: Roth, G-R #=6: Haasz 97 #=7: Haasz 97 + Davis at low E bbb.fchemygwi= fchemygwi # Factor multiplying chemical sputtering gas yield; PF wall bbb.fchemygwo= fchemygwo # Factor multiplying chemical sputtering gas yield; Outer wall bbb.fchemylb= fchemylb # Factor multiplying chemical sputtering gas yield; Left plate bbb.fchemyrb= fchemyrb # Factor multiplying chemical sputtering gas yield; Right plate # Physical #- - - - - - bbb.isph_sput[ingc]=3 # Physical sputtering model #=0: old fixed case #=1: DIVIMP/JET physical sputtering fits #=2: adds H+ chemical sputtering #=3: adds H0 carbon sputtering bbb.crmb=bbb.minu[0] # Mass of incident sputtering particles bbb.cizb=bbb.ziin[0] # Max plasma charge state bbb.fphysylb= fphysylb # Factor multiplying physical sputtering gas yield; Left plate bbb.fphysyrb= fphysyrb # Factor multiplying physical sputtering gas yield; Right plate # Wall sputtering #- - - - - - bbb.isi_sputw[ingc]=isi_sputw # Outer wall sputtering model #=0: no ion sputtering #=1: adds physical ion sputtering #=2: adds chemical ion sputtering bbb.isi_sputpf[2]=isi_sputpf # PF wall sputtering: as above bbb.t_wall=t_wall # Side wall temperatures bbb.t_plat=t_plat # Plate temperatures """---------------------------------------------------------------------------------------------------- ALLOCATE CARBON ARRAYS ----------------------------------------------------------------------------------------------------""" if bbb.pyrestart_file[0].decode('UTF-8')!='read': bbb.allocate()