### Install Aurora from Source Source: https://github.com/fsciortino/aurora/blob/master/docs/install.md Use this command to install the latest version of Aurora directly from its source code repository. ```bash python setup.py install ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/fsciortino/aurora/blob/master/CMakeLists.txt Sets the minimum required CMake version and defines the project name and languages (C, Fortran). ```cmake cmake_minimum_required(VERSION 3.17.2...3.26) project(${SKBUILD_PROJECT_NAME} LANGUAGES C Fortran) ``` -------------------------------- ### Install Aurora via PyPI Source: https://github.com/fsciortino/aurora/blob/master/docs/install.md Install the latest release of Aurora using pip, the Python Package Installer. ```bash pip install aurorafusion ``` -------------------------------- ### Installing Python Extension Source: https://github.com/fsciortino/aurora/blob/master/CMakeLists.txt Installs the '_aurora' Python extension module into the 'aurora/' directory of the Python site-packages. ```cmake install(TARGETS _aurora DESTINATION aurora/) ``` -------------------------------- ### Generating F2PY Wrappers Source: https://github.com/fsciortino/aurora/blob/master/CMakeLists.txt Defines a custom command to generate C wrappers and Fortran example files using numpy.f2py. It depends on the specified Fortran source files. ```cmake add_custom_command( OUTPUT _auroramodule.c example-f2pywrappers.f DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/aurora/main.f90" "${CMAKE_CURRENT_SOURCE_DIR}/aurora/impden.f90" "${CMAKE_CURRENT_SOURCE_DIR}/aurora/math.f90" "${CMAKE_CURRENT_SOURCE_DIR}/aurora/grids.f90" VERBATIM COMMAND "${Python_EXECUTABLE}" -m numpy.f2py "${CMAKE_CURRENT_SOURCE_DIR}/aurora/main.f90" "${CMAKE_CURRENT_SOURCE_DIR}/aurora/impden.f90" "${CMAKE_CURRENT_SOURCE_DIR}/aurora/math.f90" "${CMAKE_CURRENT_SOURCE_DIR}/aurora/grids.f90" -m _aurora --lower) ``` -------------------------------- ### Load Gacode Input Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Loads kinetic profiles from a sample input.gacode file for ionization equilibrium comparisons. Ensure the 'example.input.gacode' file is available in the 'examples' directory. ```python import omfit_gapy inputgacode = omfit_gapy.OMFITgacode('example.input.gacode') ``` -------------------------------- ### Extract and Plot TRIM Impurity Sputtering Data and Fits Source: https://github.com/fsciortino/aurora/blob/master/docs/surface_data.md This example demonstrates how to extract and plot TRIM-calculated impurity sputtering data and their corresponding Bohdansky fit curves using the Aurora library. It requires matplotlib for plotting and assumes the Aurora package is installed and accessible. ```python import matplotlib.pyplot as plt import sys import os # Make sure that package home is added to sys.path sys.path.append("../") import aurora # Select impurity, two different projectiles and wall material imp = 'He' projectile_1 = 'He' projectile_2 = 'N' target = 'W' # Select angle of incidence angle = 65 # degrees # Extract the TRIM-generated data for the impurity sputtering yield # for the selected impurity implanted in the surface, hit by # different projectiles, in function of the impact energy, specifying # the incidence angle of the projectile onto the surface # Note: such data are for now available only for He implanted in W # D as projectile energies_1 = aurora.surface.get_impurity_sputtering_data(imp, projectile_1, target, angle)["energies"] concentrations_1 = aurora.surface.get_impurity_sputtering_data(imp, projectile_1, target, angle)["impurity_concentrations"] data_1 = aurora.surface.get_impurity_sputtering_data(imp, projectile_1, target, angle)["data"] # N as projectile energies_2 = aurora.surface.get_impurity_sputtering_data(imp, projectile_2, target, angle)["energies"] concentrations_2 = aurora.surface.get_impurity_sputtering_data(imp, projectile_2, target, angle)["impurity_concentrations"] data_2 = aurora.surface.get_impurity_sputtering_data(imp, projectile_2, target, angle)["data"] # Extract the Bohdansky fit for the sputtering yield (normalized) # to the impurity concentration into the bulk material) at the # same incidence angle of the projectile onto the surface # D as projectile energies_1_fit = aurora.surface.impurity_sputtering_coeff_fit(imp, projectile_1, target, angle)["energies"] data_1_fit = aurora.surface.impurity_sputtering_coeff_fit(imp, projectile_1, target, angle)["normalized_data"] ``` -------------------------------- ### Get Recommended TRIM Files Source: https://github.com/fsciortino/aurora/blob/master/docs/surface_data.md Retrieves a dictionary of recommended TRIM data files for use with Aurora. The file extension indicates the data type. ```python from aurora.surface import trim_files_dict trim_files = trim_files_dict() print(trim_files) ``` -------------------------------- ### Build Julia support for Aurora Source: https://github.com/fsciortino/aurora/blob/master/README.rst Build the Julia sysimage for Aurora if Julia is installed. This can speed up Julia code execution from Python but is not mandatory. ```bash make julia ``` -------------------------------- ### Set Simulation Duration Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Define the start and end times for the Aurora simulation. ```python namelist["timing"]["times"] = [0,0.2] ``` -------------------------------- ### Install Aurora via Conda Source: https://github.com/fsciortino/aurora/blob/master/docs/install.md Install Aurora using conda from the conda-forge channel. This is an alternative to pip installation. ```bash conda install -c conda-forge aurorafusion ``` -------------------------------- ### Build Julia Sysimage for Aurora Source: https://github.com/fsciortino/aurora/blob/master/docs/install.md Clean the Julia build and create a sysimage for Aurora's Julia source code. This is a one-time setup to speed up subsequent Python-Julia interface runs. ```bash make clean_julia; make julia ``` -------------------------------- ### Load Default Namelist Source: https://github.com/fsciortino/aurora/blob/master/docs/params.md Loads the default input parameter namelist for Aurora simulations. This provides a starting dictionary with all available parameters and their default values. ```default import aurora namelist = aurora.default_nml.load_default_namelist() ``` -------------------------------- ### Get Main Ion Density Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Calculates the main ion density from electron density and impurity ion dictionaries. Ensure 'ions' is correctly formatted. ```python ni_cm3 = aurora.get_main_ion_dens(ne_cm3, ions) ``` -------------------------------- ### Getting F2PY Include Directory Source: https://github.com/fsciortino/aurora/blob/master/CMakeLists.txt Executes a Python command to find the include directory for F2PY, which is necessary for compiling Fortran code with Python extensions. ```cmake execute_process( COMMAND "${PYTHON_EXECUTABLE}" -c "import numpy.f2py; print(numpy.f2py.get_include())" OUTPUT_VARIABLE F2PY_INCLUDE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) ``` -------------------------------- ### Load Default Namelist and Input Data Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Loads the default Aurora namelist and necessary input data from Gfile and Gacode for simulation setup. Ensures necessary libraries like numpy and matplotlib are imported. ```python import aurora import numpy as np import matplotlib.pyplot as plt namelist = aurora.load_default_namelist() from omfit_classes import omfit_eqdsk, omfit_gapy geqdsk = omfit_eqdsk.OMFITgeqdsk('example.gfile') inputgacode = omfit_gapy.OMFITgacode('example.input.gacode') kp = namelist['kin_profs'] kp['Te']['rhop'] = kp['ne']['rhop'] = np.sqrt(inputgacode['polflux']/inputgacode['polflux'][-1]) kp['ne']['vals'] = inputgacode['ne']*1e13 # 1e19 m^-3 --> cm^-3 kp['Te']['vals'] = inputgacode['Te']*1e3 # keV --> eV imp = namelist['imp'] = 'Ar' namelist["main_element"] = "D" namelist["timing"]["times"] = [0,0.2] namelist["source_type"] = "const" namelist["source_rate"] = 2e20 # particles/s ``` -------------------------------- ### Set Up and Run Aurora Simulation Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Initializes the Aurora simulation with the configured namelist and magnetic equilibrium. Sets constant transport coefficients and runs the simulation. ```python asim = aurora.aurora_sim(namelist, geqdsk=geqdsk) D_z = 1e4 * np.ones(len(asim.rvol_grid)) V_z = -2e2 * np.ones(len(asim.rvol_grid)) out = asim.run_aurora(D_z, V_z, plot=True) ``` -------------------------------- ### Create Time Grid with Custom Parameters Source: https://github.com/fsciortino/aurora/blob/master/docs/params.md Demonstrates how to load a default namelist, modify timing parameters, and create a time grid using the `create_time_grid` function. The last values in `dt_start`, `steps_per_cycle`, and `dt_increase` are noted as not being used except in specific modeling scenarios (sawteeth). ```default import aurora namelist = aurora.default_nml.load_default_namelist() namelist['timing']['times'] = [0.,0.5, 1.] namelist['timing']['dt_start'] = [1e-4,1e-4,1e-4] # last value not actually used, except when sawteeth are modelled! namelist['timing']['steps_per_cycle'] = [5, 5, 1] # last value not actually used, except when sawteeth are modelled! namelist['timing']['dt_increase'] = [1.005, 1.02, 1.0] # last value not actually used, except when sawteeth are modelled! time, save = aurora.create_time_grid(namelist['timing'], plot=True) ``` -------------------------------- ### Run OEDGE Simulation and Postprocess Results Source: https://github.com/fsciortino/aurora/blob/master/docs/external_codes.md This snippet demonstrates setting up an OEDGE case, loading and modifying input files, running the simulation, loading output, and calculating Balmer line components using AMJUEL rates. It requires the aurora and matplotlib libraries. ```python import aurora import matplotlib.pyplot as plt plt.ion() shot = 38996 time_s = 3.5 label = "osm_test" casename = f"oedge_AUG_{shot}_{int(time_s*1e3)}_{label}" # set up an OEDGE case osm = aurora.oedge_case(shot, (t0 + t1) / 2.0, label=label) # load a specific input file osm.load_input_file(filepath="/path/to/my/file.d6i") # possibly modify specific parts of the input file: osm.inputs["+P01"]["data"] = 22 # update input file osm.write_input_file(filepath="/path/to/my/file.d6i") # now run simulation osm.run(grid_loc="/path/to/my/grid/file.sno") # once simulation is run, load the output osm.load_output() # now, initialize emission calculation am = aurora.h_am_pecs() # extract relevant fields from the OEDGE run ne_m3 = osm.output.read_data_2d("KNBS") Te_eV = osm.output.read_data_2d("KTEBS") Ti_eV = osm.output.read_data_2d("KTIBS") n_H2_m3 = osm.output.read_data_2d("PINMOL") n_H_m3 = osm.output.read_data_2d("PINATO") # load all contributions predicted by AMJUEL cH, cHp, cH2, cH2p, cH2m = am.load_pec( ne_m3, Te_eV, ne_m3, # ni=ne n_H_m3, n_H2_m3, series="balmer", choice="alpha", plot=False, ) fig, axs = plt.subplots(1, 5, figsize=(25, 6), sharex=True) osm.output.plot_2d(cH, ax=axs[0]) axs[0].set_title("cH") osm.output.plot_2d(cHp, ax=axs[1]) axs[1].set_title("cHp") osm.output.plot_2d(cH2, ax=axs[2]) axs[2].set_title("cH2") osm.output.plot_2d(cH2p, ax=axs[3]) axs[3].set_title("cH2p") osm.output.plot_2d(cH2m, ax=axs[4]) axs[4].set_title("cH2m") plt.tight_layout() ``` -------------------------------- ### Initialize Aurora Simulation Source: https://github.com/fsciortino/aurora/blob/master/docs/params.md Creates the main simulation object 'asim' using the modified namelist and the geqdsk file. This is the final step before running the simulation. ```default asim = aurora.core.aurora_sim(namelist, geqdsk=geqdsk) ``` -------------------------------- ### Get Atomic Data Source: https://github.com/fsciortino/aurora/blob/master/docs/atomic_data.md Retrieves atomic data for a specified ion, including ionization and recombination coefficients. ```python ion = 'Ca' atom_data = aurora.get_atom_data(ion,['scd','acd']) ``` -------------------------------- ### Load and Plot SOLPS-ITER Results Source: https://github.com/fsciortino/aurora/blob/master/docs/external_codes.md Demonstrates loading SOLPS-ITER results from MDS+ or disk files and plotting plasma density and temperature. Requires SOLPS output files. ```python """ Script to demonstrate capabilities to load and post-process SOLPS results. Note that SOLPS output is not distributed with Aurora; so, in order to run this script, either you are able to access the default AUG SOLPS MDS+ server, or you need to appropriately modify the script to point to your own SOLPS results. """ import numpy as np import matplotlib.pyplot as plt plt.ion() from omfit_classes import omfit_eqdsk import sys, os import aurora # if one wants to load a SOLPS case from MDS+ (defaults for AUG): so = aurora.solps_case(solps_id=141349) # alternatively, one may want to load SOLPS results from files on disk/cluster: # indicate here the absolute path of your SOLPS run folder in the same format as in the example! ################################################################################################ path = "/absolute/path/of/your/SOLPS/run/folder" ################################################################################################ rev_path = path[::-1] i = len(path) - rev_path.index('/') - 1 baserun_path = path[:i] + "/baserun" so = aurora.solps_case( b2fstate_path = path + "/b2fstate", b2fgmtry_path = baserun_path + "/b2fgmtry", ) # plot some important fields fig, axs = plt.subplots(1, 2, figsize=(10, 6), sharex=True) ax = axs.flatten() so.plot2d_b2(so.data("ne"), ax=ax[0], scale="log", label=r"$n_e$ [$m^{-3}$]") so.plot2d_b2(so.data("te"), ax=ax[1], scale="linear", label=r"$T_e$ [eV]") if hasattr(so, "fort46") and hasattr(so, "fort44"): # if EIRENE data files (e.g. fort.44, .46, etc.) are available, # one can plot EIRENE results on the original EIRENE grid. # SOLPS results also include EIRENE outputs on B2 grid fig, axs = plt.subplots(1, 2, figsize=(10, 6), sharex=True) so.plot2d_eirene( so.fort46["pdena"][:, 0] * 1e6, scale="log", label=r"$n_n$ [$m^{-3}$]", ax=axs[0], ) so.plot2d_b2(so.fort44["dab2"][:, :, 0].T, label=r"$n_n$ [$m^{-3}$]", ax=axs[1]) plt.tight_layout() ``` -------------------------------- ### Set Up Time-Independent Kinetic Profiles Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Configure time-independent kinetic profiles for electron density and temperature, ensuring they are on the rhop grid. Inputs are expected in CGS units. ```python kp = namelist['kin_profs'] kp['Te']['rhop'] = kp['ne']['rhop'] = np.sqrt(inputgacode['polflux']/inputgacode['polflux'][-1]) kp['ne']['vals'] = inputgacode['ne']*1e13 # 1e19 m^-3 --> cm^-3 kp['Te']['vals'] = inputgacode['Te']*1e3 # keV --> eV ``` -------------------------------- ### Initialize Aurora Simulation Object Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Create the main Aurora simulation object using the prepared namelist and magnetic equilibrium data. This object holds all necessary inputs for the forward model. ```python asim = aurora.aurora_sim(namelist, geqdsk=geqdsk) ``` -------------------------------- ### Import Aurora Library Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Import the main Aurora library to begin using its functionalities. ```python import aurora ``` -------------------------------- ### Initialize PWI Simulation Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Initializes the Aurora simulation using the `aurora_sim_pwi` class, which is specifically adapted for full Plasma-Wall Interaction (PWI) modeling. This class takes the configured namelist andgeqdsk file as input. ```python asim = aurora.pwi.aurora_sim_pwi(namelist, geqdsk=geqdsk) ``` -------------------------------- ### Building Fortran Object Library Source: https://github.com/fsciortino/aurora/blob/master/CMakeLists.txt Creates a static library 'fortranobject' from F2PY's fortranobject.c. It links against Python's NumPy and includes the F2PY include directory. Position-independent code is enabled. ```cmake add_library(fortranobject OBJECT "${F2PY_INCLUDE_DIR}/fortranobject.c") target_link_libraries(fortranobject PUBLIC Python::NumPy) target_include_directories(fortranobject PUBLIC "${F2PY_INCLUDE_DIR}") set_property(TARGET fortranobject PROPERTY POSITION_INDEPENDENT_CODE ON) ``` -------------------------------- ### Extracting TRIM Reflection Data Source: https://github.com/fsciortino/aurora/blob/master/docs/surface_data.md Extracts TRIM-calculated particle (rn) and energy (re) reflection coefficients for a given projectile, target, and angle of incidence. Use this to get the raw simulation data. ```python import matplotlib.pyplot as plt import sys import os # Make sure that package home is added to sys.path sys.path.append("../") import aurora # Select two different projectiles and wall material projectile_1 = 'He' projectile_2 = 'Ar' target = 'W' # Select angle of incidence angle = 65 # degrees # Extract the TRIM-generated data for the particle and energy # reflection coefficients for the selected impurity hitting # the surface, in function of the impact energy, specifying # the incidence angle of the projectile onto the surface # He as projectile energies_rn_1 = aurora.surface.get_reflection_data(projectile_1, target, angle, 'rn')["energies"] # energy values of the particle refl. coeff. data_rn_1 = aurora.surface.get_reflection_data(projectile_1, target, angle, 'rn')["data"] # particle reflection coeff. energies_re_1 = aurora.surface.get_reflection_data(projectile_1, target, angle, 're')["energies"] # energy values of the energy refl. coeff. data_re_1 = aurora.surface.get_reflection_data(projectile_1, target, angle, 're')["data"] # energy refl. coeff. # N as projectile energies_rn_2 = aurora.surface.get_reflection_data(projectile_2, target, angle, 'rn')["energies"] # energy values of the particle refl. coeff data_rn_2 = aurora.surface.get_reflection_data(projectile_2, target, angle, 'rn')["data"] # particle refl. coeff. energies_re_2 = aurora.surface.get_reflection_data(projectile_2, target, angle, 're')["energies"] # energy values of the energy refl. coeff. data_re_2 = aurora.surface.get_reflection_data(projectile_2, target, angle, 're')["data"] # energy refl. coeff. ``` -------------------------------- ### Get He-like Spectrum Data Source: https://github.com/fsciortino/aurora/blob/master/docs/atomic_data.md Retrieves spectral data for a specified ion, including contributions from Li-like, He-like, and H-like charge states. Allows for wavelength shifting and plotting of all lines. ```python out= aurora.get_local_spectrum(filepath_he, ion, ne_cm3, Te_eV, n0_cm3=0.0, ion_exc_rec_dens=[fz[0,-4], fz[0,-3], fz[0,-2]], # Li-like, He-like, H-like dlam_A = 0.0, plot_spec_tot=False, no_leg=True, plot_all_lines=True, ax=None) wave_final_he, spec_ion_he, spec_exc_he, spec_rec_he, spec_dr_he, spec_cx_he, ax = out ``` -------------------------------- ### Load Default Namelist and Initialize Plasma Profiles Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Loads the default namelist and initializes kinetic profiles for electron density and temperature using data from a GACode input file. Sets the impurity species to Helium and the main element to Deuterium. Configures simulation timing and source rate. ```python import aurora import numpy as np import matplotlib.pyplot as plt namelist = aurora.load_default_namelist() from omfit_classes import omfit_eqdsk, omfit_gapy geqdsk = omfit_eqdsk.OMFITgeqdsk('example.gfile') inputgacode = omfit_gapy.OMFITgacode('example.input.gacode') kp = namelist['kin_profs'] kp['Te']['rhop'] = kp['ne']['rhop'] = np.sqrt(inputgacode['polflux']/inputgacode['polflux'][-1]) kp['ne']['vals'] = inputgacode['ne']*1e13 # 1e19 m^-3 --> cm^-3 kp['Te']['vals'] = inputgacode['Te']*1e3 # keV --> eV imp = namelist['imp'] = 'He' namelist["main_element"] = "D" namelist["timing"]["times"] = [0,1.0] namelist["source_type"] = "const" namelist["source_rate"] = 2e20 # particles/s ``` -------------------------------- ### Import Aurora and Matplotlib Source: https://github.com/fsciortino/aurora/blob/master/docs/surface_data.md Initializes the necessary libraries for data analysis and plotting. Ensure the Aurora package path is correctly added to sys.path. ```python import matplotlib.pyplot as plt import sys import os # Make sure that package home is added to sys.path sys.path.append("../") import aurora ``` -------------------------------- ### Add Turbulent Transport Coefficients Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Adds turbulent diffusion (Dz_an) and convection (Vz_an) coefficients to the FACIT-calculated neoclassical coefficients. This example sets turbulent transport inside and outside the pedestal. ```default Dz_an = np.zeros(D_z.shape) # space, time, nZ Vz_an = np.zeros(D_z.shape) # estimate pedestal top position and find radial index of separatrix rped = 0.90 idxped = np.argmin(np.abs(rped - asim.rhop_grid)) idxsep = np.argmin(np.abs(1.0 - asim.rhop_grid)) # core turbulent transport coefficients Dz_an[:idxped,:,:] = 1e4 # cm^2/s Vz_an[:idxped,:,:] = -1e2 # cm/s # SOL transport coefficients Dz_an[idxsep:,:,:] = 1e4 # cm^2 Vz_an[idxsep:,:,:] = -1e2 # cm/s D_z += Dz_an V_z += Vz_an ``` -------------------------------- ### Initialize Transport Coefficients and Magnetic Geometry Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Initializes arrays for transport coefficients and magnetic geometry, preparing for FACIT calculations. Note the dummy time dimension required for charge-dependent coefficients. ```default # note that to be able to give charge-dependent Dz and Vz, # one has to give also time dependence (see documentation of aurora.core.run_aurora()) times_DV = np.array([0]) # note that to be able to give charge-dependent Dz and Vz, # one has to give also time dependence (see documentation of aurora.core.run_aurora()), # so a dummy time dimension with only one element is introduced here nz_init = np.zeros((asim.rvol_grid.size, asim.Z_imp+1)) D_z = np.zeros((asim.rvol_grid.size, times_DV.size, asim.Z_imp+1)) # space, time, nZ V_z = np.zeros(D_z.shape) # flux surface contours (when rotation_model = 2) RV, ZV = aurora.rhoTheta2RZ(geqdsk, rhop, theta, coord_in='rhop', n_line=201) RV, ZV = RV.T, ZV.T ``` -------------------------------- ### Import Utility Libraries Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Import necessary Python libraries for numerical operations and plotting. ```python import numpy as np import matplotlib.pyplot as plt ``` -------------------------------- ### Extracting Eckstein Fit Reflection Coefficients Source: https://github.com/fsciortino/aurora/blob/master/docs/surface_data.md Extracts the parameters for the Eckstein empirical fit of particle (rn) and energy (re) reflection coefficients. Use this to get the fitted curves for comparison with TRIM data. ```python # Extract the Eckstein fits for both the coefficients at the # same incidence angle of the projectile onto the surface # He as projectile energies_rn_fit_1 = aurora.surface.reflection_coeff_fit(projectile_1, target, angle, 'rn')["energies"] # energy values of the particle refl. coeff. data_rn_fit_1 = aurora.surface.reflection_coeff_fit(projectile_1, target, angle, 'rn')["data"] # particle refl. coeff. energies_re_fit_1 = aurora.surface.reflection_coeff_fit(projectile_1, target, angle, 're')["energies"] # energy values of the energy refl. coeff. data_re_fit_1 = aurora.surface.reflection_coeff_fit(projectile_1, target, angle, 're')["data"] # energy refl. coeff. ``` -------------------------------- ### Get Atomic Data Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Retrieves atomic effective ionization ('scd') and recombination ('acd') data for a specified element (e.g., 'Ca') from default ADAS files. The adas_files_dict() function can be used to see the default files. ```python atom_data = aurora.get_atom_data('Ca',['scd','acd']) ``` -------------------------------- ### Define and Plot Kinetic Profiles Source: https://github.com/fsciortino/aurora/blob/master/docs/params.md This snippet shows how to load default namelist parameters, define radial grid points (rhop), and set electron density (ne) and electron temperature (Te) values. It then plots these profiles against the normalized poloidal flux. ```default import aurora import numpy as np import matplotlib.pyplot as plt namelist = aurora.default_nml.load_default_namelist() rhop = namelist["kin_profs"]["ne"]["rhop"] = namelist["kin_profs"]["Te"]["rhop"] = np.linspace(0, 1, 100) ne = namelist["kin_profs"]["ne"]["vals"] = (1e14 - 0.4e14) * (1 - rhop ** 2) ** 0.5 + 0.4e14 Te = namelist["kin_profs"]["Te"]["vals"] = (5000 - 100) * (1 - rhop ** 2) ** 1.5 + 100 fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(14, 5)) ax[0].plot(rhop,ne) ax[1].plot(rhop,Te) ax[0].set_xlabel(r'$ ho_p$') ax[1].set_xlabel(r'$ ho_p$') ax[0].set_ylabel('$n_e$ [cm$^{{-3}}$]') ax[1].set_ylabel('$T_e$ [eV]') ax[0].set_ylim((0,None)) ax[1].set_ylim((0,None)) ``` -------------------------------- ### Extracting Surface Sputtering Data Source: https://github.com/fsciortino/aurora/blob/master/docs/surface_data.md Retrieves TRIM-generated bulk sputtering yield (Y) and energy sputtering yield (YE) data for specified projectiles, target, and incidence angle. Use this to get raw simulation results for analysis. ```python projectile_1 = 'He' projectile_2 = 'Ar' target = 'W' angle = 55 # degrees # Extract TRIM data for projectile 1 energies_y_1 = aurora.surface.get_bulk_sputtering_data(projectile_1, target, angle, 'y')["energies"] # energy values of the sputtering yields data_y_1 = aurora.surface.get_bulk_sputtering_data(projectile_1, target, angle, 'y')["data"] # sputtering yields energies_ye_1 = aurora.surface.get_bulk_sputtering_data(projectile_1, target, angle, 'ye')["energies"] # energy values of the energy sputtering yields data_ye_1 = aurora.surface.get_bulk_sputtering_data(projectile_1, target, angle, 'ye')["data"] # energy sputtering yields # Extract TRIM data for projectile 2 energies_y_2 = aurora.surface.get_bulk_sputtering_data(projectile_2, target, angle, 'y')["energies"] # energy values of the sputtering yields data_y_2 = aurora.surface.get_bulk_sputtering_data(projectile_2, target, angle, 'y')["data"] # sputtering yields energies_ye_2 = aurora.surface.get_bulk_sputtering_data(projectile_2, target, angle, 'ye')["energies"] # energy values of the energy sputtering yields data_ye_2 = aurora.surface.get_bulk_sputtering_data(projectile_2, target, angle, 'ye')["data"] # energy sputtering yields ``` -------------------------------- ### Create and Plot Radial Grid Source: https://github.com/fsciortino/aurora/blob/master/docs/params.md This snippet demonstrates how to create a radial grid using a namelist dictionary and visualize it. Ensure the 'aurora' library is imported and default namelist is loaded. Parameters like K, dr_0, dr_1, rvol_lcfs, lim_sep, and bound_sep control the grid's characteristics. ```python import aurora namelist = aurora.default_nml.load_default_namelist() namelist['K'] = 6. namelist['dr_0'] = 1.0 # 1 cm spacing near axis namelist['dr_1'] = 0.1 # 0.1 cm spacing at the edge namelist['rvol_lcfs'] = 50.0 # cm, minor radius (in rvol units) namelist['lim_sep'] = 3.0 # cm, distance between LCFS and limiter shadow namelist['bound_sep'] = 5.0 # cm, distance between LCFS and wall boundary rvol_grid, pro_grid, qpr_grid, prox_param = aurora.create_radial_grid(namelist, plot=True) ``` -------------------------------- ### Run Aurora Simulation with Plotting Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Execute the Aurora simulation with visualization options enabled for time traces and plasma-wall interaction data. ```python out = asim.run_aurora(D_z, v_z, plot=True, plot_PWI=True) ``` -------------------------------- ### Load Default Aurora Namelist Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Load the default namelist configuration for Aurora simulations. ```python namelist = aurora.load_default_namelist() ``` -------------------------------- ### Read Magnetic Equilibrium Data Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Load magnetic equilibrium data from a geqdsk file using OMFIT. ```python geqdsk = omfit_eqdsk.OMFITgeqdsk('example.gfile') ``` -------------------------------- ### Time Discretization of Density Evolution Source: https://github.com/fsciortino/aurora/blob/master/docs/model.md Implicit time discretization scheme for density evolution, weighting contributions from previous and new time steps. ```latex \overline{n}_i^{j+1} + \overline{n}_i^{j} & = \Delta t \overline{Q}_i \\ & + \Delta t \left[ \tilde{D}_{i-} + \left[ 1 + K_{i-1/2} \right] \tilde{v}_{i-} \right] \left( \tilde{n}_{i-1}^{j+1} + \tilde{n}_{i-1}^j \right) \\ & - \Delta t \left[ \tilde{D}_{i-} - \left[ 1 - K_{i-1/2} \right] \tilde{v}_{i-} \right] \left( \tilde{n}_{i}^{j+1} + \tilde{n}_{i}^j \right) \\ & + \Delta t \left[ \tilde{D}_{i+} - \left[ 1 + K_{i+1/2} \right] \tilde{v}_{i+} \right] \left( \tilde{n}_{i}^{j+1} + \tilde{n}_{i}^j \right) \\ & + \Delta t \left[ \tilde{D}_{i+} - \left[ 1 - K_{i+1/2} \right] \tilde{v}_{i+} \right] \left( \tilde{n}_{i+1}^{j+1} + \tilde{n}_{i+1}^j \right) \\ ``` -------------------------------- ### Run Aurora Simulation Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Execute the Aurora simulation with the specified transport coefficients. Setting plot=True will automatically display result plots. ```python out = asim.run_aurora(D_z, V_z, plot=True) ``` -------------------------------- ### Set Wall Material Composition Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Specifies the bulk material composition for both the main and divertor walls. This is a prerequisite for the full PWI model. ```python namelist['full_PWI']['main_wall_material'] = 'W' namelist['full_PWI']['div_wall_material'] = 'W' ``` -------------------------------- ### Generate and Plot Step Source Time History Source: https://github.com/fsciortino/aurora/blob/master/docs/params.md Use this snippet to create a step-function particle source and visualize its time history. Ensure the 'aurora' and 'numpy' libraries are imported. ```python import aurora import numpy as np namelist = aurora.default_nml.load_default_namelist() namelist['source_type'] = 'step' namelist['src_step_times'] = [0, 0.4 ,0.6] namelist['src_step_rates'] = [0, 1e20, 0] source_time_history = aurora.get_source_time_history(namelist, Raxis_cm = 50, time = np.linspace(0,1,1000), plot = True) ``` -------------------------------- ### Calculate Reflection Coefficients Source: https://github.com/fsciortino/aurora/blob/master/docs/surface_data.md Calculates particle and energy reflection coefficients for a given projectile, target, and angle. Extracts energy values and reflection coefficient data. ```python energies_rn_fit_2 = aurora.surface.reflection_coeff_fit(projectile_2, target, angle, 'rn')["energies"] # energy values of the particle refl. coeff. data_rn_fit_2 = aurora.surface.reflection_coeff_fit(projectile_2, target, angle, 'rn')["data"] # particle refl. coeff. energies_re_fit_2 = aurora.surface.reflection_coeff_fit(projectile_2, target, angle, 're')["energies"] # energy values of the energy refl. coeff. data_re_fit_2 = aurora.surface.reflection_coeff_fit(projectile_2, target, angle, 're')["data"] # energy refl. coeff. ``` -------------------------------- ### Rebuild Aurora from Source with Makefile Source: https://github.com/fsciortino/aurora/blob/master/docs/install.md Clean previous builds and recompile Aurora from source by modifying the Makefile. This provides greater control over the compiler. ```bash make clean; make ``` -------------------------------- ### Activate Recycling Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Enables the recycling of particles in the simulation. ```python namelist['recycling_flag'] = True ``` -------------------------------- ### Calculate Fractional Abundances Source: https://github.com/fsciortino/aurora/blob/master/docs/atomic_data.md Calculates the fractional abundances of charge states for a given ion at specified electron density and temperature. This is useful for weighting spectral contributions. ```python ne_cm3 = 1e14 Te_eV = 1e3 Te, fz = aurora.get_frac_abundances(atom_data, np.array([ne_cm3,]), np.array([Te_eV,]), plot=False) ``` -------------------------------- ### Calculate Radiation Model (Fractional Impurity Density) Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Calculates the most important radiation terms at a single time slice, assuming impurity densities are a fraction of electron density. Useful for parameter scans. ```default res = aurora.radiation_model(imp,rhop,ne_cm3,Te_eV, geqdsk, n0_cm3=None, frac=0.005, plot=True) ``` -------------------------------- ### Load and Process A&M Reactions Database Source: https://github.com/fsciortino/aurora/blob/master/docs/atomic_data.md Loads the AMJUEL/HYDHEL reactions database for evaluating atomic and molecular rates. This is used for calculating components of spectral lines like the Balmer series. ```python import os, copy import numpy as np import matplotlib.pylab as plt plt.ion() import sys # Make sure that package home is added to sys.path sys.path.append("../") import aurora rdb = aurora.amdata.reactions_database() ``` -------------------------------- ### Adding Python Extension Module Source: https://github.com/fsciortino/aurora/blob/master/CMakeLists.txt Adds a Python MODULE library named '_aurora' using the generated C wrapper and Fortran source files. It links against the 'fortranobject' library. ```cmake python_add_library(_aurora MODULE "${CMAKE_CURRENT_BINARY_DIR}/_auroramodule.c" "${CMAKE_CURRENT_SOURCE_DIR}/aurora/main.f90" "${CMAKE_CURRENT_SOURCE_DIR}/aurora/impden.f90" "${CMAKE_CURRENT_SOURCE_DIR}/aurora/math.f90" "${CMAKE_CURRENT_SOURCE_DIR}/aurora/grids.f90" WITH_SOABI) target_link_libraries(_aurora PRIVATE fortranobject) ``` -------------------------------- ### Animate Aurora Simulation Results Source: https://github.com/fsciortino/aurora/blob/master/docs/tutorial.md Generate an MP4 animation of the simulated charge state densities over time and radius. This function requires the radial grid, time points, charge state densities, and labeling information. ```python aurora.animate_aurora(asim.rhop_grid, asim.time_out, nz.transpose(1,0,2), xlabel=r'$ ho_p$', ylabel='t={:.4f} [s]', zlabel=r'$n_z$ [A.U.]', labels=[str(i) for i in np.arange(0,nz.shape[1])], plot_sum=True, save_filename='aurora_anim') ```