def gensettings(B, T=5e3, Z=1, E=0.04, n=2e19, pMax=56): """ Generate appropriate DREAM settings. B: Magnetic field strength. T: Electron temperature. E: Effective charge of plasma. E: Electric field (in units of critical electric field). n: Electron density. yMax: Maximum momentum (normalized to thermal momentum) on computational grid. """ global nTimeSteps c = scipy.constants.c e = scipy.constants.e eps0 = 8.85418782e-12 me = 9.10938e-31 vth = np.sqrt(2*e*T / me) lnLambda = 14.9-0.5*np.log(n/1e20) + np.log(T/1e3) Ec = n*lnLambda*(e**3) / (4*np.pi*(eps0**2)*me*(c**2)) nu0 = n*e**4*lnLambda / (4*np.pi*eps0**2*me**2*(vth)**3) ds = DREAMSettings() ds.collisions.lnlambda = Collisions.LNLAMBDA_THERMAL ds.eqsys.E_field.setPrescribedData(E) ds.eqsys.n_i.addIon(name='Ion', Z=Z, n=n/Z, iontype=IonSpecies.IONS_PRESCRIBED_FULLY_IONIZED) # Imaginary ion with charge Z ds.eqsys.T_cold.setPrescribedData(T) ds.eqsys.f_hot.setInitialProfiles(n0=n, T0=T) ds.eqsys.f_hot.setSynchrotronMode(DistFunc.SYNCHROTRON_MODE_INCLUDE) ds.eqsys.f_hot.setBoundaryCondition(DistFunc.BC_F_0) ds.eqsys.f_hot.setAdvectionInterpolationMethod(ad_int=DistFunc.AD_INTERP_QUICK) ds.eqsys.n_re.setAvalanche(avalanche=Runaways.AVALANCHE_MODE_NEGLECT) Np = 105 Nxi = 20 ds.hottailgrid.setNxi(Nxi) ds.hottailgrid.setNp(Np) ds.hottailgrid.setPmax(pMax) ds.hottailgrid.setBiuniformGrid(psep=1.5, npsep=20, thetasep=0.5, nthetasep_frac=0.5) ds.runawaygrid.setEnabled(False) ds.radialgrid.setB0(B) ds.radialgrid.setMinorRadius(0.1) ds.radialgrid.setWallRadius(0.1) ds.radialgrid.setNr(1) tMax_CODE = 600e3 tMax = tMax_CODE / nu0 ds.timestep.setTmax(tMax) ds.timestep.setNt(nTimeSteps) ds.output.setTiming(stdout=True) return ds
def _runScan(self, index, scanParameter): """ Run an individual DREAM simulation corresponding to index 'index' in the scan parameter 'scanParameter'. index: Index in scan of this simulation. scanParameter: Name of scan parameter settings specifying the scan. """ sp = self.scanParameters[scanParameter] self._status(':: Scan {} ({}/{}) in parameter {}'.format( index, index - sp['startindex'] + 1, sp['nvalues'], scanParameter)) # Skip the baseline case if index == 0: self._status(':: Skipping baseline case') return self.baselineOutput, sp['baseline'] f = sp['f'] # Copy DREAMSettings object ns = DREAMSettings(self.settings, chain=False) # Modify the settings ns, scanValue = f(index, ns, sp['baseline']) return runiface.runiface(ns), scanValue
def gensettings(T, Z=300, EED=1e-6, n=5e19, yMax=5): """ Generate appropriate DREAM settings. T: Electron temperature. Z: Effective charge of plasma. EEc: Electric field (in units of critical electric field). n: Electron density. yMax: Maximum momentum (normalized to thermal momentum) on computational grid. """ global NR, R0 betaTh = DREAM.Formulas.getNormalizedThermalSpeed(T) pMax = yMax * betaTh ED = DREAM.Formulas.getED(T,n) ds = DREAMSettings() ds.collisions.lnlambda = Collisions.LNLAMBDA_THERMAL ds.eqsys.E_field.setPrescribedData(EED*ED) ds.eqsys.n_i.addIon(name='Ion', Z=Z, n=n/Z, iontype=IonSpecies.IONS_PRESCRIBED_FULLY_IONIZED) # Imaginary ion with charge Z ds.eqsys.T_cold.setPrescribedData(T) ds.eqsys.f_hot.setInitialProfiles(rn0=0, n0=n, rT0=0, T0=T) ds.eqsys.n_re.setAvalanche(avalanche=Runaways.AVALANCHE_MODE_NEGLECT) ds.eqsys.j_ohm.setCorrectedConductivity(JOhm.CORRECTED_CONDUCTIVITY_DISABLED) ds.eqsys.j_ohm.setConductivityMode(JOhm.CONDUCTIVITY_MODE_SAUTER_COLLISIONLESS) # set non-uniform xi grid with cells stradding the trapped-passing boundaries ds.hottailgrid.setTrappedPassingBoundaryLayerGrid(xi0Trapped, dxiMax=0.1, boundaryLayerWidth=1e-4) ds.hottailgrid.setNp(40) ds.hottailgrid.setPmax(pMax) ds.runawaygrid.setEnabled(False) mu0 = scipy.constants.mu_0 a = 0.3 rref = np.linspace(0, a, 20) Ipref = 2e5 psiref = -mu0 * Ipref * (1-(rref/a)**2) ds.radialgrid.setType(RadialGrid.TYPE_ANALYTIC_TOROIDAL) ds.radialgrid.setMajorRadius(R0) ds.radialgrid.setShaping(psi=psiref, rpsi=rref, kappa=1.5, delta=0.1, GOverR0=2.0) ds.radialgrid.setMinorRadius(a) ds.radialgrid.setWallRadius(a) ds.radialgrid.setNr(NR) # Simulate for 3.5 ms at T = 1 keV, and scale # appropriately depending on actual temperature tMax = 3.5e-3 * np.power(T / 1e3, 1.5) ds.timestep.setTmax(tMax) ds.timestep.setNt(3) return ds
def gensettings(T, Z=1, E=2, n=5e19, yMax=20): """ Generate appropriate DREAM settings. T: Electron temperature. E: Effective charge of plasma. E: Electric field (in units of critical electric field). n: Electron density. yMax: Maximum momentum (normalized to thermal momentum) on computational grid. """ betaTh = DREAM.Formulas.getNormalizedThermalSpeed(T) pMax = yMax * betaTh Ec = DREAM.Formulas.getEc(T, n) ds = DREAMSettings() ds.collisions.lnlambda = Collisions.LNLAMBDA_THERMAL ds.eqsys.E_field.setPrescribedData(E) ds.eqsys.n_i.addIon(name='Ion', Z=Z, n=n / Z, iontype=IonSpecies.IONS_PRESCRIBED_FULLY_IONIZED ) # Imaginary ion with charge Z ds.eqsys.n_cold.setPrescribedData(n) ds.eqsys.T_cold.setPrescribedData(T) ds.eqsys.f_hot.setInitialProfiles(rn0=0, n0=n, rT0=0, T0=T) ds.eqsys.n_re.setAvalanche(avalanche=Runaways.AVALANCHE_MODE_NEGLECT) ds.eqsys.f_hot.setAdvectionInterpolationMethod(ad_int=FHot.AD_INTERP_QUICK) ds.hottailgrid.setNxi(20) ds.hottailgrid.setNp(100) ds.hottailgrid.setPmax(pMax) ds.runawaygrid.setEnabled(False) ds.radialgrid.setB0(1) ds.radialgrid.setMinorRadius(0.1) ds.radialgrid.setWallRadius(0.1) ds.radialgrid.setNr(1) tMax0 = pMax * Ec / E ds.timestep.setTmax(.9 * tMax0) ds.timestep.setNt(nTimeSteps) ds.other.include('fluid/runawayRate', 'fluid/gammaDreicer') """ If using MUMPS, computation time can be reduced by 30%: ds.solver.setLinearSolver(Solver.LINEAR_SOLVER_MUMPS) """ return ds
def gensettings(T, Z=1, EEc=1e-2, n=5e19, yMax=5): """ Generate appropriate DREAM settings. T: Electron temperature. Z: Effective charge of plasma. EEc: Electric field (in units of critical electric field). n: Electron density. yMax: Maximum momentum (normalized to thermal momentum) on computational grid. """ betaTh = DREAM.Formulas.getNormalizedThermalSpeed(T) pMax = yMax * betaTh Ec = DREAM.Formulas.getEc(T, n) ds = DREAMSettings() ds.collisions.lnlambda = Collisions.LNLAMBDA_THERMAL ds.eqsys.E_field.setPrescribedData(EEc * Ec) ds.eqsys.n_i.addIon(name='Ion', Z=Z, n=n / Z, iontype=IonSpecies.IONS_PRESCRIBED_FULLY_IONIZED ) # Imaginary ion with charge Z ds.eqsys.T_cold.setPrescribedData(T) ds.eqsys.f_hot.setInitialProfiles(rn0=0, n0=n, rT0=0, T0=T) ds.eqsys.n_re.setAvalanche(avalanche=Runaways.AVALANCHE_MODE_NEGLECT) ds.hottailgrid.setNxi(12) ds.hottailgrid.setNp(80) ds.hottailgrid.setPmax(pMax) ds.runawaygrid.setEnabled(False) ds.radialgrid.setB0(1) ds.radialgrid.setMinorRadius(0.1) ds.radialgrid.setWallRadius(0.1) ds.radialgrid.setNr(1) # Simulate for 3.5 ms at T = 1 keV, and scale # appropriately depending on actual temperature tMax = 3.5e-3 * np.power(T / 1e3, 1.5) ds.timestep.setTmax(tMax) ds.timestep.setNt(2) return ds
sys.path.append('../../py/') from DREAM import runiface from DREAM.DREAMSettings import DREAMSettings import DREAM.Settings.Equations.IonSpecies as Ions import DREAM.Settings.Solver as Solver import DREAM.Settings.CollisionHandler as Collisions import DREAM.Settings.Equations.ColdElectronTemperature as T_cold import DREAM.Settings.Equations.ElectricField as Efield import DREAM.Settings.Equations.HotElectronDistribution as FHot from DREAM.Settings.Equations.ElectricField import ElectricField from DREAM.Settings.Equations.ColdElectronTemperature import ColdElectronTemperature ds = DREAMSettings() # set collision settings ds.collisions.collfreq_mode = Collisions.COLLFREQ_MODE_FULL ds.collisions.collfreq_type = Collisions.COLLFREQ_TYPE_PARTIALLY_SCREENED ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_STOPPING_POWER ds.collisions.lnlambda = Collisions.LNLAMBDA_ENERGY_DEPENDENT ############################# # Set simulation parameters # ############################# # time resolution of restarted simulation Tmax_restart = 1e-3 # simulation time in seconds Nt_restart = 20 # number of time steps
import DREAM.Settings.Equations.IonSpecies as Ions import DREAM.Settings.Solver as Solver import DREAM.Settings.TransportSettings as Transport import DREAM.Settings.CollisionHandler as Collisions import DREAM.Settings.Equations.ElectricField as Efield import DREAM.Settings.Equations.RunawayElectrons as RE import DREAM.Settings.Equations.HotElectronDistribution as FHot import DREAM.Settings.Equations.ColdElectronTemperature as T_cold from DREAM.Settings.Equations.ElectricField import ElectricField from DREAM.Settings.Equations.ColdElectronTemperature import ColdElectronTemperature from DREAM import DREAMIO ds = DREAMSettings() # set collision settings ###################### # COLLISION SETTINGS # ###################### ds.collisions.collfreq_mode = Collisions.COLLFREQ_MODE_SUPERTHERMAL ds.collisions.collfreq_type = Collisions.COLLFREQ_TYPE_PARTIALLY_SCREENED # NON_SCREENED, PARTIALLY_SCREENED, COMPLETELY_SCREENED ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_STOPPING_POWER ds.collisions.lnlambda = Collisions.LNLAMBDA_ENERGY_DEPENDENT ds.collisions.pstar_mode = Collisions.PSTAR_MODE_COLLISIONAL run_init = True run_exp = True
# ################################################################### import numpy as np import sys sys.path.append('../../py/') from DREAM.DREAMSettings import DREAMSettings import DREAM.Settings.Equations.IonSpecies as Ions import DREAM.Settings.Solver as Solver import DREAM.Settings.CollisionHandler as Collisions ############################## # PART I ############################## ds1 = DREAMSettings() E = 0.3 # Electric field strength (V/m) n = 5e19 # Electron density (m^-3) T = 1e3 # Temperature (eV) # Set E_field ds1.eqsys.E_field.setPrescribedData(E) # Set temperature ds1.eqsys.T_cold.setPrescribedData(T) # Set ions ds1.eqsys.n_i.addIon(name='D', Z=1, iontype=Ions.IONS_PRESCRIBED_FULLY_IONIZED,
from DREAM.DREAMOutput import DREAMOutput from DREAM import runiface import DREAM.Settings.Equations.IonSpecies as Ions import DREAM.Settings.Solver as Solver import DREAM.Settings.CollisionHandler as Collisions import DREAM.Settings.Equations.ElectricField as Efield import DREAM.Settings.Equations.RunawayElectrons as RE import DREAM.Settings.Equations.HotElectronDistribution as FHot import DREAM.Settings.Equations.ColdElectronTemperature as T_cold import DREAM.Settings.TimeStepper as TimeStep import DREAM.Settings.Equations.SPI as SPI from DREAM.Settings.Equations.ElectricField import ElectricField from DREAM.Settings.Equations.ColdElectronTemperature import ColdElectronTemperature ds = DREAMSettings() # set collision settings ds.collisions.collfreq_mode = Collisions.COLLFREQ_MODE_FULL ds.collisions.collfreq_type = Collisions.COLLFREQ_TYPE_PARTIALLY_SCREENED #ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_NEGLECT ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_STOPPING_POWER #ds.collisions.lnlambda = Collisions.LNLAMBDA_CONSTANT ds.collisions.lnlambda = Collisions.LNLAMBDA_ENERGY_DEPENDENT ds.collisions.pstar_mode = Collisions.PSTAR_MODE_COLLISIONAL ############################# # Set simulation parameters # ############################# # time resolution of restarted simulation
import DREAM.Settings.Equations.RunawayElectrons as RE import DREAM.Settings.Equations.HotElectronDistribution as FHot import DREAM.Settings.Equations.ColdElectronTemperature as T_cold import DREAM.Settings.TimeStepper as TimeStep from DREAM.Settings.Equations.ElectricField import ElectricField from DREAM.Settings.Equations.ColdElectronTemperature import ColdElectronTemperature run_ioniz=True run_expdecay=True run_CQ=True filename_ending="Tf100-50_Nr101" ds = DREAMSettings() # set collision settings ds.collisions.collfreq_mode = Collisions.COLLFREQ_MODE_FULL ds.collisions.collfreq_type = Collisions.COLLFREQ_TYPE_PARTIALLY_SCREENED #ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_NEGLECT ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_STOPPING_POWER #ds.collisions.lnlambda = Collisions.LNLAMBDA_CONSTANT ds.collisions.lnlambda = Collisions.LNLAMBDA_ENERGY_DEPENDENT ds.collisions.pstar_mode = Collisions.PSTAR_MODE_COLLISIONAL ############################# # Set simulation parameters # ############################# Tmax_PostTQ = 40e-3
def gensettings(T=10, EOverEcTot=None, nD0=1e20, nD1=0, nAr=0, nNe=0): """ Generate DREAM settings object. T: Electron temperature. (enters calculation only via lnLambda) EOverEcTot: Electric field (in units of critical electric field). nD0: Density of ionised hydrogen. nD1: Density of neutral hydrogen. nAr: Density of neutral argon. nNe: Density of neutral neon. """ ###################### # PHYSICAL CONSTANTS # ###################### c = scipy.constants.c # speed of light ec = scipy.constants.e # elementary charge eps0 = scipy.constants.epsilon_0 # vacuum permittivity me = scipy.constants.m_e # electron mass ######################### # RESOLUTION PARAMETERS # ######################### pOverPc = 20 # pMax / pc, with pc an estimate of the critical momentum Nxi = 15 # number of xi grid points Np = 60 # number of momentum grid points tMaxToP = 30 # time for collisionless acceleration to p/mc=tMaxToP ################################ # SIMULATION PLASMA PARAMETERS # ################################ nTot = nD0 + nD1 + nAr * 18 + nNe * 10 # total (free plus bound) electron density nFree = nD1 # free electron density lnLambda = 14.9 - 0.5 * np.log(nFree / 1e20) + np.log(T / 1e3) EcTot = nTot * lnLambda * (ec**3) / (4 * np.pi * (eps0**2) * me * (c**2)) E = EcTot * EOverEcTot # Set pMax to a multiple of the critical momentum (in the nonscreened limit) # up to a maximum value of pMaxMax pcTot = 1 / np.sqrt(E / EcTot - 1) pMax = pOverPc * pcTot pMaxMax = 10 if pMax > pMaxMax: pMax = pMaxMax ds = DREAMSettings() ds.collisions.lnlambda = Collisions.LNLAMBDA_ENERGY_DEPENDENT ds.collisions.collfreq_mode = Collisions.COLLFREQ_MODE_SUPERTHERMAL ds.collisions.collfreq_type = Collisions.COLLFREQ_TYPE_PARTIALLY_SCREENED ds.eqsys.E_field.setPrescribedData(E) ds.eqsys.n_i.addIon(name='D_ionized', Z=1, n=nD0, iontype=IonSpecies.IONS_PRESCRIBED_FULLY_IONIZED) ds.eqsys.n_i.addIon(name='D_neutral', Z=1, n=nD1, iontype=IonSpecies.IONS_PRESCRIBED_NEUTRAL) ds.eqsys.n_i.addIon(name='Ar', Z=18, n=nAr, iontype=IonSpecies.IONS_PRESCRIBED_NEUTRAL) ds.eqsys.n_i.addIon(name='Ne', Z=10, n=nNe, iontype=IonSpecies.IONS_PRESCRIBED_NEUTRAL) ds.eqsys.T_cold.setPrescribedData(T) # initialize f_hot to something small but smooth in order for the # advection interpolation coefficients to converge but n_hot be # negligible compared to n_re(t=0) ds.eqsys.f_hot.setInitialProfiles(n0=0.01, T0=1e5) ds.eqsys.f_hot.setAdvectionInterpolationMethod(ad_int=FHot.AD_INTERP_TCDF) ds.eqsys.f_hot.setBoundaryCondition(FHot.BC_F_0) ds.eqsys.n_re.setAvalanche(avalanche=Runaways.AVALANCHE_MODE_KINETIC, pCutAvalanche=0.01) ds.eqsys.n_re.setEceff(Eceff=Runaways.COLLQTY_ECEFF_MODE_SIMPLE) ds.eqsys.n_re.setInitialProfile( density=1) # arbitrary initial value for n_re to seed the avalanche ds.eqsys.f_hot.enableIonJacobian(False) ds.hottailgrid.setNxi(Nxi) ds.hottailgrid.setNp(Np) ds.hottailgrid.setPmax(pMax) ds.runawaygrid.setEnabled(False) ds.radialgrid.setB0(1e-6) ds.radialgrid.setMinorRadius(0.1) ds.radialgrid.setWallRadius(0.1) ds.radialgrid.setNr(1) tMax = tMaxToP * me * c / ((E - EcTot) * ec) ds.timestep.setTmax(tMax) ds.timestep.setNt(nTimeSteps) ds.solver.setType(Solver.NONLINEAR) ds.solver.tolerance.set(reltol=1e-4) ds.solver.setVerbose(True) ds.other.include('fluid') return ds
import DREAM.Settings.Solver as Solver import DREAM.Settings.CollisionHandler as Collisions import DREAM.Settings.Equations.ElectricField as Efield import DREAM.Settings.Equations.RunawayElectrons as RE import DREAM.Settings.Equations.HotElectronDistribution as FHot import DREAM.Settings.Equations.ColdElectronTemperature as T_cold import DREAM.Settings.TimeStepper as TimeStep import DREAM.Settings.Equations.SPI as SPI import DREAM.Settings.TransportSettings as Transport from DREAM.Settings.Equations.ElectricField import ElectricField from DREAM.Settings.Equations.ColdElectronTemperature import ColdElectronTemperature np.random.seed(1) ds = DREAMSettings() # set collision settings ds.collisions.collfreq_mode = Collisions.COLLFREQ_MODE_FULL ds.collisions.collfreq_type = Collisions.COLLFREQ_TYPE_PARTIALLY_SCREENED #ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_NEGLECT ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_STOPPING_POWER #ds.collisions.lnlambda = Collisions.LNLAMBDA_CONSTANT ds.collisions.lnlambda = Collisions.LNLAMBDA_ENERGY_DEPENDENT ds.collisions.pstar_mode = Collisions.PSTAR_MODE_COLLISIONAL ############################# # Set simulation parameters # ############################# run_init = False run_injection_init = False
import DREAM.Settings.Equations.RunawayElectrons as RE import DREAM.Settings.Equations.HotElectronDistribution as FHot import DREAM.Settings.Equations.ColdElectronTemperature as T_cold import DREAM.Settings.TimeStepper as TimeStep from DREAM.Settings.Equations.ElectricField import ElectricField from DREAM.Settings.Equations.ColdElectronTemperature import ColdElectronTemperature run_ioniz=True run_expdecay=True run_CQ_init=True run_CQ=True run_decay=False ds = DREAMSettings() filename_ending="Tf100-50_Nr101" # set collision settings ds.collisions.collfreq_mode = Collisions.COLLFREQ_MODE_FULL ds.collisions.collfreq_type = Collisions.COLLFREQ_TYPE_PARTIALLY_SCREENED #ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_NEGLECT ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_STOPPING_POWER #ds.collisions.lnlambda = Collisions.LNLAMBDA_CONSTANT ds.collisions.lnlambda = Collisions.LNLAMBDA_ENERGY_DEPENDENT ds.collisions.pstar_mode = Collisions.PSTAR_MODE_COLLISIONAL ############################# # Set simulation parameters # #############################
import numpy as np import sys sys.path.append('../../py/') from DREAM import runiface from DREAM.DREAMSettings import DREAMSettings import DREAM.Settings.Equations.ColdElectronTemperature as T_cold import DREAM.Settings.Equations.ElectricField as Efield import DREAM.Settings.Equations.HotElectronDistribution as FHot import DREAM.Settings.Equations.IonSpecies as Ions import DREAM.Settings.Equations.RunawayElectrons as Runaways import DREAM.Settings.Solver as Solver import DREAM.Settings.TransportSettings as Transport ds = DREAMSettings() # Physical parameters n = 5e19 # Electron density (m^-3) T = 10e3 # Temperature (eV) Ip0 = 1e6 # Initial plasma current (A) # Grid parameters pMax = 1 # maximum momentum in units of m_e*c Np = 150 # number of momentum grid points Nxi = 6 # number of pitch grid points tMax = 1e-3 # simulation time in seconds Nt = 30 # number of time steps Nr = 4 # number of radial grid points
sys.path.append('../../py/') from DREAM.ConvergenceScan import ConvergenceScan from DREAM.ConvergenceScanPlot import ConvergenceScanPlot from DREAM.DREAMSettings import DREAMSettings import DREAM.Settings.Equations.HotElectronDistribution as FHot import DREAM.Settings.Equations.IonSpecies as Ions import DREAM.Settings.Equations.RunawayElectrons as Runaways import DREAM.Settings.Solver as Solver import DREAM.Settings.CollisionHandler as Collisions ############################### # 1. Set up baseline scenario ############################### ds = DREAMSettings() #E = 0.3 # Electric field strength (V/m) E = 6.745459970079014 n = 5e19 # Electron density (m^-3) #T = 1e3 # Temperature (eV) T = 100 # Set E_field ds.eqsys.E_field.setPrescribedData(E) # Set temperature ds.eqsys.T_cold.setPrescribedData(T) # Set ions ds.eqsys.n_i.addIon(name='D', Z=1, iontype=Ions.IONS_PRESCRIBED_FULLY_IONIZED, n=n)
def generateSettings(analyticB=False): """ Generates a DREAMSettings object for the test :param bool analyticB: If ``True``, uses an analytic magnetic field. Otherwise a numeric magnetic field is used. """ global ROOT T = 3e3 # eV E = 2 # V/m n = 5e19 # m^-3 yMax = 20 # thermal momentum Z = 1 # plasma charge betaTh = DREAM.Formulas.getNormalizedThermalSpeed(T) pMax = yMax * betaTh Ec = DREAM.Formulas.getEc(T, n) ds = DREAMSettings() ds.collisions.lnlambda = Collisions.LNLAMBDA_THERMAL ds.eqsys.E_field.setPrescribedData(E) ds.eqsys.n_i.addIon(name='Ion', Z=Z, n=n / Z, iontype=IonSpecies.IONS_PRESCRIBED_FULLY_IONIZED ) # Imaginary ion with charge Z ds.eqsys.n_cold.setPrescribedData(n) ds.eqsys.T_cold.setPrescribedData(T) ds.eqsys.f_hot.setInitialProfiles(rn0=0, n0=n, rT0=0, T0=T) ds.eqsys.n_re.setAvalanche(avalanche=Runaways.AVALANCHE_MODE_NEGLECT) ds.eqsys.f_hot.setAdvectionInterpolationMethod(ad_int=FHot.AD_INTERP_QUICK) ds.hottailgrid.setNxi(20) ds.hottailgrid.setNp(100) ds.hottailgrid.setPmax(pMax) ds.runawaygrid.setEnabled(False) # Get magnetic field shaping parameters rG_R0, G_R0, rpsi, psi, rDelta, Delta, rkappa, kappa, rdelta, delta = getShapeProfiles( ) if analyticB: ds.radialgrid.setType(RadialGrid.TYPE_ANALYTIC_TOROIDAL) ds.radialgrid.setShaping(psi=psi / Rp, rpsi=rpsi, GOverR0=G_R0, rG=rG_R0, kappa=kappa, rkappa=rkappa, delta=delta, rdelta=rdelta, Delta=Delta, rDelta=rDelta) else: FAC = 5 numdata = constructMagneticField(Rp=Rp, Zp=0, a=a, nR=FAC * 50, ntheta=FAC * 50, rG_R0=rG_R0, G_R0=G_R0, rpsi=rpsi, psi=psi, Delta=Delta, rDelta=rDelta, kappa=kappa, rkappa=rkappa, delta=delta, rdelta=rdelta, retdict=True) # Save to HDF5 file numname = '{}/magfield.h5'.format(ROOT) savenummag.saveLUKE(numname, numdata) ds.radialgrid.setNumerical(numname, format=RadialGrid.FILE_FORMAT_LUKE) ds.radialgrid.setMinorRadius(a) ds.radialgrid.setWallRadius(a) ds.radialgrid.setMajorRadius(Rp) ds.radialgrid.setNr(10) tMax0 = pMax * Ec / E ds.timestep.setTmax(.9 * tMax0) ds.timestep.setNt(5) ds.other.include('fluid/runawayRate', 'fluid/gammaDreicer') return ds
# # ################################################################### import numpy as np import sys sys.path.append('../../py/') from DREAM.DREAMSettings import DREAMSettings import DREAM.Settings.Equations.DistributionFunction as DistFunc import DREAM.Settings.Equations.IonSpecies as Ions import DREAM.Settings.Equations.RunawayElectrons as Runaways import DREAM.Settings.Solver as Solver import DREAM.Settings.CollisionHandler as Collisions ds = DREAMSettings() #ds.collisions.collfreq_type = Collisions.COLLFREQ_TYPE_COMPLETELY_SCREENED ds.collisions.collfreq_type = Collisions.COLLFREQ_TYPE_PARTIALLY_SCREENED # Physical parameters E = 6 # Electric field strength (V/m) n = 5e19 # Electron density (m^-3) T = 100 # Temperature (eV) # Grid parameters pMax = 1 # maximum momentum in units of m_e*c Np = 300 # number of momentum grid points Nxi = 20 # number of pitch grid points tMax = 1e-3 # simulation time in seconds Nt = 20 # number of time steps
import sys sys.path.append('../../py/') from DREAM.ConvergenceScan import ConvergenceScan from DREAM.ConvergenceScanPlot import ConvergenceScanPlot from DREAM.DREAMSettings import DREAMSettings import DREAM.Settings.Equations.HotElectronDistribution as FHot import DREAM.Settings.Equations.IonSpecies as Ions import DREAM.Settings.Solver as Solver import DREAM.Settings.CollisionHandler as Collisions ############################### # 1. Set up baseline scenario ############################### ds = DREAMSettings() #E = 0.3 # Electric field strength (V/m) E = 6.745459970079014 n = 5e19 # Electron density (m^-3) #T = 1e3 # Temperature (eV) T = 100 # Set E_field ds.eqsys.E_field.setPrescribedData(E) # Set temperature ds.eqsys.T_cold.setPrescribedData(T) # Set ions ds.eqsys.n_i.addIon(name='D',
from DREAM.DREAMSettings import DREAMSettings from DREAM.DREAMOutput import DREAMOutput from DREAM import runiface import DREAM.Settings.Equations.IonSpecies as Ions import DREAM.Settings.Solver as Solver import DREAM.Settings.CollisionHandler as Collisions import DREAM.Settings.Equations.ElectricField as Efield import DREAM.Settings.Equations.RunawayElectrons as RE import DREAM.Settings.Equations.HotElectronDistribution as FHot import DREAM.Settings.Equations.ColdElectronTemperature as T_cold from DREAM.Settings.Equations.ElectricField import ElectricField from DREAM.Settings.Equations.ColdElectronTemperature import ColdElectronTemperature ds = DREAMSettings() # set collision settings ds.collisions.collfreq_mode = Collisions.COLLFREQ_MODE_FULL ds.collisions.collfreq_type = Collisions.COLLFREQ_TYPE_PARTIALLY_SCREENED #ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_NEGLECT ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_STOPPING_POWER #ds.collisions.lnlambda = Collisions.LNLAMBDA_CONSTANT ds.collisions.lnlambda = Collisions.LNLAMBDA_ENERGY_DEPENDENT ds.collisions.pstar_mode = Collisions.PSTAR_MODE_COLLISIONAL # ds.eqsys.n_re.setEceff(Eceff=RE.COLLQTY_ECEFF_MODE_SIMPLE) ############################# # Set simulation parameters # #############################
sys.path.append('../../py/') from DREAM.DREAMSettings import DREAMSettings from DREAM import runiface import DREAM.Settings.Equations.IonSpecies as Ions import DREAM.Settings.Solver as Solver import DREAM.Settings.CollisionHandler as Collisions import DREAM.Settings.Equations.ElectricField as Efield import DREAM.Settings.Equations.HotElectronDistribution as FHot import DREAM.Settings.Equations.ColdElectronTemperature as T_cold from DREAM.Settings.Equations.ElectricField import ElectricField from DREAM.Settings.Equations.ColdElectronTemperature import ColdElectronTemperature ds = DREAMSettings() # set collision settings ds.collisions.collfreq_mode = Collisions.COLLFREQ_MODE_FULL ds.collisions.collfreq_type = Collisions.COLLFREQ_TYPE_PARTIALLY_SCREENED #ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_NEGLECT ds.collisions.bremsstrahlung_mode = Collisions.BREMSSTRAHLUNG_MODE_STOPPING_POWER #ds.collisions.lnlambda = Collisions.LNLAMBDA_CONSTANT ds.collisions.lnlambda = Collisions.LNLAMBDA_ENERGY_DEPENDENT ############################# # Set simulation parameters # ############################# Tmax_restart2 = 1e-4 Nt_restart2 = 50