Commit 14a8fd8f authored by Fabian Wieschollek's avatar Fabian Wieschollek

Alles

parent eeadae21
*.o
*.mod
*.dep
*.h5
*.tar
*.tar.gz
*.tar.bz2
*.tgz
*.err
*.out
*.log
*.dat
*.swp
*.i90
*.orig
*.pyc
*.xml
*.png
*.csv
*.optrpt
j302_1
j302_3
.fuse_hidden*
jorek_model*
jorek_*_model*
jorek2_poincare
jorek2_four
jorek2_postproc*
jorek2_povray
jorek2_connection2*
jorek2_connection_stan
jorek2_strikes
enbiggen
jordel
jorpol
jorek2_stan
jorek2vtk*
jorek2_fieldlines_vtk
jorek2vtk_3d
jorek2_diagno*
jorek_to_helena
import_eqdsk
jorek2_main
jorek2_target2vtk
jorek2_powers
jorek2_import_perturbation
jorek2_import_perturbation_new_flags
jorek2_import_perturbation_new_flags
jorek2_import_perturbation_tmp
jorek_extract_data
forcheck*
*__genmod*
rst_bin2hdf5
rst_hdf52bin
tmp[1-9]*
.info
.mod/
.dep/
.obj/
version.h
starwall-response.dat
coil_field.dat
RMP_psi*.txt
RMP_start_time.dat
shard_size.dat
non_regression_tests_*
/test_*
# Makefile for compiling fortran programs with automatic dependency
# generation and recognition of programs. Full support for parallel make.
#
# Object files are stored in $(OBJDIR)=.obj/
# Module files are stored in $(MODDIR)=.mod/
# Dependencies are stored in $(DEPDIR)=.dep/
#
# Known limitations:
# - Module/function/subroutine name must be equal to file name
# Include jorek-specific things and settings
include Makefile.inc
# Default rule needs to be first
main: jorek2_radiative
# Some defaults and parsing logic for makefile.inc
include defaults.mk
# Build the main executable with a different name from the source file jorek2_radiative.o
jorek2_radiative: $(OBJDIR)/jorek2_radiative.o $(shell ./util/obj_deps $(DEPDIR)/jorek2_radiative.d)
$(FC) $(FLAGS) $(DEFINES) $(INCLUDES) -o $@ $^ $(LIBS)
.PHONY: clean cleanall cleandep duplicates
cleanall: clean cleandep
clean:
@echo ">> Deleting Object Files <<"
-@rm -r $(OBJDIR)
@echo ">> Deleting Module Files <<"
-@rm -r $(MODDIR)
-@find . -name '*.mod' -delete -or -name '*.o' -delete
cleandep:
@echo ">> Deleting Dependency Files <<"
-@rm -r $(DEPDIR)
-@find . -name '*.d' -delete 2>/dev/null
doc docs:
-@rm -r doc/ # workaround for FORD bug
ford jorek.md --no-search $(INCLUDES)
# Directories containing sources, ordered by number of files
DIRS := tools \
. \
radiative
DIRS+=$(EXTRA_DIRS) # Specified in Makefile.inc or commandline
# All .f90 files we should generate .d dependency files for
depends:=$(basename $(notdir $(shell find $(DIRS) -maxdepth 1 -iname '*.f90')))
depends:=$(foreach dep,$(depends),$(DEPDIR)/$(dep).d)
# Check for multiple files with the same name in $(DIRS)
duplicates:
@dups=`find $(DIRS) -maxdepth 1 -iname '*.f90' |\
xargs basename -s .f90 -a | sort | uniq -d`
@if [[ -z "${dups// }" ]]; then echo "No duplicates detected"; \
else echo "Duplicates found: ${dups}"; fi
printsettings:
@echo "FC = $(FC)"
@echo "CC = $(CC)"
@echo "DEBUG = $(DEBUG)"
@echo "FLAGS = $(FLAGS)"
@echo "FFLAGS = $(FFLAGS)"
@echo "F90FLAGS = $(F90FLAGS)"
@echo "F77FLAGS = $(F77FLAGS)"
@echo "CFLAGS = $(CFLAGS)"
@echo "DEFINES = $(DEFINES)"
@echo "INCLUDES = $(INCLUDES)"
@echo "LIBS = $(LIBS)"
# For each source dir add an explicit rule with the template
$(foreach dir,$(DIRS),$(eval $(call O_TEMPLATE,$(dir)/)))
# For each source dir add a rule to create dependency files
ifneq (cleanall,$(findstring cleanall,$(MAKECMDGOALS)))
ifneq (cleandep,$(findstring cleandep,$(MAKECMDGOALS)))
$(foreach dir,$(DIRS),$(eval $(call F90_D_TEMPLATE,$(dir)/)))
endif
endif
# Include the dependency files that can be generated by the rules above
-include $(depends) # Make will build all of these and re-execute
# The included programs are defined in the $(depends) files
# For each of these programs add the default template
$(foreach prog,$(PROGRAM_SOURCES),$(eval $(call PROGRAM_TEMPLATE,$(prog))))
# To compile all programs found in $(DIRS)
all: $(basename $(notdir $(PROGRAM_SOURCES)))
# A list of supported diagnostics, that should compile properly for regression
# testing to pass
most: jorek2_radiative
# Make all object files we know of
find_files = $(wildcard $(dir)/*.f90) $(wildcard $(dir)/*.c) $(wildcard $(dir)/*.f) $(wildcard $(dir)/*.cpp)
objs: $(foreach file,$(foreach dir,$(DIRS), $(find_files)), $(OBJDIR)/$(notdir $(basename $(file))).o)
# Special cases
# Add here: Global includes (as the line below)
INCLUDES += -Itools # for r3_info.h
INCLUDES += -Imodels
# C++ support
LIBS += -lstdc++
CXXFLAGS += -pedantic -Wall
# JOREK configuration file for compilation on the DRACO cluster at IPP Garching
# see also https://www.jorek.eu/wiki/doku.php?id=draco
FC = mpiifort -mcmodel=large
CC = mpiicc
CXX = mpiicpc
USE_PASTIX = 1
# --- PaStiX solver
PASTIX_HOME = /u/mhoelzl/LIBS/2018/pastix_release_4492
LIB_PASTIX = `$(PASTIX_HOME)/install/pastix-conf --libs`
LIB_PASTIX_MURGE = `$(PASTIX_HOME)/install/pastix-conf --libs_murge`
LIB_PASTIX_BLAS = `$(PASTIX_HOME)/install/pastix-conf --blas`
INC_PASTIX = `$(PASTIX_HOME)/install/pastix-conf --incs`
DEBUG ?= 0 # Build in release mode by default
# To use the default compiler flags, set $(COMPILER_FAMILY)
# If you do not want to do this, be sure to set OUTPUT_MODULE_COMMAND to the correct
# one for your compiler in Makefile.inc.
# build in directories to not clutter the repository
MODDIR := .mod
OBJDIR := .obj
DEPDIR := .dep
$(shell mkdir -p $(MODDIR) $(OBJDIR) $(DEPDIR) >/dev/null)
INCLUDES += -I$(MODDIR)
# Detect the compiler vendors (sort to remove duplicates)
F_COMPILER_FAMILY :=$(sort $(shell $(FC) --version | grep -oim 1 'intel\|gcc\|gnu' | tr A-Z a-z | sed 's/gcc/gnu/'))
C_COMPILER_FAMILY :=$(sort $(shell $(CC) --version | grep -oim 1 'intel\|gcc\|gnu' | tr A-Z a-z | sed 's/gcc/gnu/'))
CXX_COMPILER_FAMILY :=$(sort $(shell $(CXX) --version | grep -oim 1 'intel\|gcc\|gnu\|g[+][+]' | tr A-Z a-z | sed -e 's/gcc/gnu/' -e 's/g[+][+]/gnu/'))
ifneq ($(F_COMPILER_FAMILY),$(C_COMPILER_FAMILY))
$(error "Fortran compiler ($(F_COMPILER_FAMILY)) must be same as C compiler ($(C_COMPILER_FAMILY))")
endif
ifneq ($(CXX_COMPILER_FAMILY),$(C_COMPILER_FAMILY))
$(error "C++ compiler ($(CXX_COMPILER_FAMILY)) must be same as C compiler ($(C_COMPILER_FAMILY))")
endif
ifeq ($(COMPILER_FAMILY),)
COMPILER_FAMILY = $(F_COMPILER_FAMILY)
endif
ifneq ($(F_COMPILER_FAMILY),$(COMPILER_FAMILY))
$(warning "*******************************************************************************************")
$(warning "Set compiler family ($(COMPILER_FAMILY)) is different from $(FC) ($(F_COMPILER_FAMILY))")
$(warning "*******************************************************************************************")
endif
# Clear some variables (makefile bug?)
F77FLAGS=
F90FLAGS=
# Default (GNU) preprocessor
GCPP ?= cpp
# Default flags for GCC
ifeq ($(COMPILER_FAMILY), gnu)
FLAGS += -cpp -fopenmp
FLAGS += -Wall -Wextra
FLAGS += -Wno-unused-variable
FFLAGS += -Wintrinsics-std
FFLAGS += -Wcharacter-truncation
FFLAGS += -Wsurprising -Wno-tabs
FFLAGS += -ffree-line-length-none
F77FLAGS += -fdefault-real-8 -fdefault-double-8
ifeq ($(DEBUG), 1)
FLAGS += -g -Og -ggdb -fno-lto
FLAGS += -Wunused-variable
FFLAGS += -fcheck=all
FLAGS += -ffpe-trap=invalid,zero,overflow,denormal
FFLAGS += -ftrapv
FFLAGS += -finit-real=snan -finit-integer=12345678
FFLAGS += -Wconversion
F90FLAGS += -fimplicit-none
endif
ifeq ($(DEBUG), 2)
FFLAGS += -Wimplicit-interface -Wimplicit-procedure
endif
FFLAGS +=-J$(MODDIR)
endif
# Default flags for intel
ifeq ($(COMPILER_FAMILY), intel)
COMPILER_MAJOR_VERSION=$(shell $(FC) -V 2>&1 | grep -o "Version [0-9]*" | cut -d' ' -f 2)
FFLAGS += -align
ifeq ($(shell test $(COMPILER_MAJOR_VERSION) -ge 15; echo $$?),0)
FLAGS += -qopenmp
else
FLAGS += -openmp
endif
FFLAGS += -warn all
FFLAGS += -warn nointerfaces
FFLAGS += -warn nounused
FFLAGS += -fpp
FFLAGS += -r8
F77FLAGS += -warn nodeclarations
ifeq ($(DEBUG), 1)
# Debug flags for ifort, see http://www.nas.nasa.gov/hecc/support/kb/recommended-intel-compiler-debugging-options_92.html
FLAGS += -O0 -g -traceback
FLAGS += -ftrapuv
FLAGS += -debug all -debug-parameters
FLAGS += -fstack-security-check
FLAGS += -fpe0
FFLAGS += -check all,noarg_temp_created
FFLAGS += -check bounds
FFLAGS += -check uninit
FFLAGS += -init=snan -init=zero
FFLAGS += -gen-interfaces -warn-interfaces
F90FLAGS += -implicitnone
endif
FFLAGS +=-module $(MODDIR)
endif
#TODO identify good default flags for XLF
# Correct preprocessor-defines for IBM XLF Compiler
IBM_DEFINES = `echo $(DEFINES) | sed -e 's/^/-WF,/' -e 's/ */,/g'`
ifdef IBMFC
DEFINES := $(IBM_DEFINES) -DIBM_MACHINE
endif
# TODO set the option to output module files to a specific directory for XLF
# Make rules for specific files
# This is needed because the file stems must match and we do not really want to recreate the directory structure in $(OBJDIR) and $(DEPDIR)
# Also, it will make everything slightly nicer later
# Template for generating object files from source files
# Touch the .mod file again if it exists (because it is not written if there is no change to the interfaces, and this messes with the make rules)
# Note that gfortran outputs module files in lowercase of the module name, while intel remains case-sensitive. Best to use lowercase module names
define O_TEMPLATE
$(OBJDIR)/%.o $(MODDIR)/%.mod:: $(1)%.f90
$$(FC) $$(FLAGS) $$(FFLAGS) $$(F90FLAGS) $$(DEFINES) $$(INCLUDES) $$(EXTRA_FLAGS) -c $$< -o $(OBJDIR)/$$*.o
@test -e $(MODDIR)/$$*.mod && touch $(MODDIR)/$$*.mod || true
$(OBJDIR)/%.o:: $(1)%.f
$$(FC) $$(FLAGS) $$(FFLAGS) $$(F77FLAGS) $$(DEFINES) $$(INCLUDES) $$(EXTRA_FLAGS) -c $$< -o $(OBJDIR)/$$*.o
$(OBJDIR)/%.o:: $(1)%.c
$$(CC) $$(FLAGS) $$(CFLAGS) $$(DEFINES) $$(INCLUDES) $$(EXTRA_FLAGS) -c $$< -o $(OBJDIR)/$$*.o
$(OBJDIR)/%.o:: $(1)%.cpp
$$(CXX) $$(FLAGS) $$(CXXFLAGS) $$(DEFINES) $$(INCLUDES) $$(EXTRA_FLAGS) -c $$< -o $(OBJDIR)/$$*.o
endef
# Template for generating dependencies from source file
define F90_D_TEMPLATE
$(DEPDIR)/%.d: $(1)%.f90 | $(MODDIR)/version.h
@echo "Generating dependencies for $$<"
@$(GCPP) -traditional-cpp -dI $$(DEFINES) $$(INCLUDES) $$< | util/makedepend $$< - $(DIRS) > $(DEPDIR)/$$(*F).d
endef
# This template defines a program $(file_stem)
# which has prerequisites $(OBJDIR)/$(file_stem).o and as determined by the output of obj_deps.sh
# Since make will try to build the .d files first and re-exec every time
# these will be up-to-date
file_stem=$(notdir $(basename $(1)))
define PROGRAM_TEMPLATE
$(notdir $(basename $(1))): $(OBJDIR)/$(file_stem).o $(shell ./util/obj_deps $(DEPDIR)/$(file_stem).d)
$$(FC) $$(FLAGS) $$(EXTRA_FLAGS) $$(DEFINES) $$(INCLUDES) -o $(file_stem) $$^ $$(LIBS)
endef
LIBS += $(LIBLAPACK) $(LIBBLAS) $(OPENMPLIB)
# Use flags
ifeq (1, $(USE_PASTIX))
DEFINES := $(DEFINES) -DUSE_PASTIX
LIBS := $(LIBS) $(LIB_PASTIX) $(LIB_PASTIX_BLAS)
INCLUDES := $(INCLUDES) $(INC_PASTIX)
PASTIX_MEMORY_USAGE?=1
ifeq (1, $(PASTIX_MEMORY_USAGE))
DEFINES := $(DEFINES) -DMEMORY_USAGE
endif
else
# This is a hack to remove the linking problems that otherwise arise
DEFINES += -Dpastix_fortran=fake_pastix_fortran
endif
# Do not check to make these files to speed up and clean -d output
Makefile: ;
Makefile.inc: ;
%.mk: ;
%.f90: ;
# Try to create .mod/version.h, but only overwrite it if the contents have changed
$(MODDIR)/version.h:
@echo "Generate .mod/version.h"
@rm -f $@.tmp
@echo "#define RCS_VERSION '`git describe --always --dirty --abbrev 2> /dev/null`'" >> $@.tmp
@echo "#define RCS_LABEL '`git log -1 --format="%s (%D)" 2> /dev/null | sed -e "s/'/''/g" `'" >> $@.tmp
@echo "#define RCS_TIME '`git log -1 --format="%ad" 2> /dev/null`'" >> $@.tmp
@echo "#define compile_command '$(FC)'" >> $@.tmp
@echo "#define compile_flags '$(FLAGS) $(FFLAGS) $(F90FLAGS) $(EXTRA_FLAGS)'" >> $@.tmp
@echo "#define compile_includes '$(INCLUDES)'" >> $@.tmp
@echo "#define compile_defines '$(DEFINES)'" >> $@.tmp
@echo "#define compile_libs '$(LIBS)'" >> $@.tmp
-@echo "#define compile_dir '`pwd`'" >> $@.tmp
-@echo "#define compile_user '`whoami`'" >> $@.tmp
-@echo "#define compile_machine '`hostname`'" >> $@.tmp
@echo "#define compile_modules '$(LOADEDMODULES)'" >> $@.tmp
@[ -f $@ ] && cmp --silent $@ $@.tmp || mv $@.tmp $@
-@rm -f $@.tmp
!> particles/examples/W_example.f90
!> Requires: acd50_w.dat, scd50_w.dat and the JOREK input file
!> Compile with `j2p W_example` and run with `W_example < in1`
!> Read fields from jorek00721.h5 and onwards and push W particles
program Radiative
use mod_openadas
use constants
use mumps_module
use pastix_module
use wsmp_module
use data_structure
use phys_module
use mod_parameters
use mod_log_params
use global_distributed_matrix
use nodes_elements
use pellet_module
use equil_info
use mod_boundary, only: boundary_from_grid
use vacuum
use vacuum_response, only: get_vacuum_response, update_response, init_wall_currents, I_coils
use vacuum_equilibrium, only: import_external_fields
use live_data
use mod_bootstrap_functions
use construct_matrix_mod, only : construct_matrix
use mod_global_matrix_structure
use mod_import_restart
use mod_export_restart
use mod_element_rtree, only: populate_element_rtree
use mod_interp
use basis_at_gaussian, only: initialise_basis
use mod_expression, only: exprs_all_int, init_expr
use mod_integrals3D
use mod_interp_splinear
use mod_non_coronal
use mod_coronal
use mpi_mod
implicit none
type(adf11_all) :: adas
type(non_coronal) :: ncor
character(len=128) :: filename
character(len=23), dimension(3) :: header = (/ 't','T', 'P_rad' /)
real*8 :: dtime, stime, ftime, tau_diff
integer :: step, nlines
! Conversion: Time JOREK->SI : 1.d0 = sqrt_m0_rho0 s
! Temperature JOREK->SI : 1.d0 = 1/(2.d0*K_BOLTZ*MU_ZERO*central_density*1.d20) K
! SI->eV : 1.d0 = 8.61733326214517743366d-5 eV
! Density JOREK->SI : 1.d0 = 1.d20*central_density m^-3
! central_density = 1.d0
! sqrt_m0_rho0 = 6.483638667465844d-007
! 1/(2.d0*K_BOLTZ*MU_ZERO*1.d20) = 288188681.82099485
! --- Prepare the evolution
write(*,*) '#### Prepare Evolution ####'
adas = read_adf11('89_w') ! ADAS Data for choosen Impurity
ncor = non_coronal(adas,20.d0,4.064627111056752d0) ! Non-Coronal-Type with initial n_e=1.d0 and T=1.e-3
stime = 0.d0 ! Simulation time (s)
tau_diff = 3.d99 ! Diffusion time (s)
filename = "tungstentest-SI.dat" ! Name of outputfile
nlines = 1 ! output every ...
dtime = 1.d0 ! 0.01d0 ! Timestep
ftime = 10000.d0 !10000.d0 ! Final time
! --- Output first line(s) for stimet=0
open(20,file=filename)
write(20,'(A,3A23)') '# ',header
call ncor%output(20)
! --- Start the Evolution
write(*,*) '##### Start Evolution #####'
write(*,*) '##### #Steps:',int(ftime/dtime),'####'
write(*,*) '##### #Lines:',int(ftime/dtime)/nlines,'###'
do step=1,int(ftime/dtime)
! --- Time step
stime=step*dtime
call ncor%update(dtime,tau_diff)
! --- Output
if ( int(mod(step,nlines)) .eq. 0 ) call ncor%output(20)
! --- Update T
call ncor%update_T(log10(10.d0**4.064627111056752d0*(1.d0+step)))
call ncor%fractions_coronal()
end do
close (20)
end program Radiative
!> particles/examples/W_example.f90
!> Requires: acd50_w.dat, scd50_w.dat and the JOREK input file
!> Compile with `j2p W_example` and run with `W_example < in1`
!> Read fields from jorek00721.h5 and onwards and push W particles
program Radiative
use mod_openadas
use constants
use mumps_module
use pastix_module
use wsmp_module
use data_structure
use phys_module
use mod_parameters
use mod_log_params
use global_distributed_matrix
use nodes_elements
use pellet_module
use equil_info
use mod_boundary, only: boundary_from_grid
use vacuum
use vacuum_response, only: get_vacuum_response, update_response, init_wall_currents, I_coils
use vacuum_equilibrium, only: import_external_fields
use live_data
use mod_bootstrap_functions
use construct_matrix_mod, only : construct_matrix
use mod_global_matrix_structure
use mod_import_restart
use mod_export_restart
use mod_element_rtree, only: populate_element_rtree
use mod_interp
use basis_at_gaussian, only: initialise_basis
use mod_expression, only: exprs_all_int, init_expr
use mod_integrals3D
use mod_interp_splinear
use mod_non_coronal
use mod_coronal
use mpi_mod
implicit none
type(adf11_all) :: adas
type(non_coronal) :: ncor
character(len=128) :: filename
character(len=23), dimension(7) :: header = (/ 't','log10_Te','log10_ne','Li0','Li1','Li2','Li3' /)
real*8 :: dtime, stime, ftime, tau_diff
integer :: step, nlines
! Conversion: Time JOREK->SI : 1.d0 = sqrt_m0_rho0 s
! Temperature JOREK->SI : 1.d0 = 1/(2.d0*K_BOLTZ*MU_ZERO*central_density*1.d20) K
! Density JOREK->SI : 1.d0 = 1.d20*central_density m^-3
! central_density = 1.d0
! sqrt_m0_rho0 = 6.483638667465844d-007
! 1/(2.d0*K_BOLTZ*MU_ZERO*1.d20) = 288188681.82099485
! --- Prepare the evolution
write(*,*) '#### Prepare Evolution ####'
adas = read_adf11('96_li') ! ADAS Data for choosen Impurity
ncor = non_coronal(adas,20.d0,5.459676920547336d0) ! Non-Coronal-Type with initial n_e=1.d0 and T=1.e-3
stime = 0.d0 ! Simulation time (s)
tau_diff = 3.d99 ! Diffusion time (s)
filename = "lithiumtest-SI.dat" ! Name of outputfile
nlines = 100 ! output every ...
dtime = 6.483638667465844d-09 ! 0.01d0 ! Timestep
ftime = 0.006483638667465844d0 !10000.d0 ! Final time
! --- Output first line(s) for stimet=0
open(20,file=filename)
write(20,'(A,13A23)') '# ',header
call ncor%output(20)
! --- Start the Evolution
write(*,*) '##### Start Evolution #####'
write(*,*) '##### #Steps:',int(ftime/dtime),'####'
write(*,*) '##### #Lines:',int(ftime/dtime)/nlines,'###'
do step=1,int(ftime/dtime)
! --- Time step
stime=step*dtime
call ncor%update(dtime,tau_diff)
! --- Output
if ( int(mod(step,nlines)) .eq. 0 ) call ncor%output(20)
! --- Update T
!call ncor%update_T(1.d-6*(1.d0+step))
end do
close (20)
end program Radiative
!> module takes the OPEN-ADAS data to calculate the non_coronal equil-
!> ibrium temperature and radiation.
!> If you need time-dependent solutions of the corona matrix timestepping look
!> in the revision history for this file.
module mod_non_coronal
use mod_openadas
use mod_interp_splinear
use constants
implicit none
private
public non_coronal
! -------------------------------------------------------------------------------------
! --- Definition of the datatype
! -------------------------------------------------------------------------------------
type non_coronal
type (ADF11_all) :: ad !< ADF11 datatype
real*8, allocatable :: fractions(:) !< Fractional charge states. Should sum to 1 but we do not check it!
real*8, allocatable :: coronal(:) !< charge states regarding coronal equilibrium. Should sum to 1 but we do not check it!
real*8, allocatable :: ion_rate(:) !< Current ionization rates (1/s)
real*8, allocatable :: rec_rate(:) !< Current recombinations rates (1/s)
real*8, allocatable :: rad(:) !< Current radiation coefficients
real*8, allocatable :: Z(:) !< The charge number at each charge state
real*8 :: density !< current log10 density (m^-3)
real*8 :: temperature !< current log10 temperature (K)
real*8 :: time !< current time (s)
real*8 :: Prad !< current log10 Radiated power per ion (W)
integer :: n_Z0 !< Z plus 1 to factor in the atomic state
contains
procedure :: update => update_fractions
procedure :: fractions_coronal => fractions_coronal
procedure :: update_T => update_T
procedure :: update_N => update_N
procedure :: update_GCRs => update_GCRs
procedure :: update_c => update_coronal
procedure :: output => output_non_coronal
procedure :: non_coronal_Prad => non_coronal_Prad
procedure :: z_EFF => z_EFF
end type non_coronal
interface non_coronal
module procedure non_coronal_equilibrium
end interface non_coronal
contains
! -------------------------------------------------------------------------------------
! --- Setup the datatype
! -------------------------------------------------------------------------------------
function non_coronal_equilibrium(ad,density,temperature) result(cor)
use constants
type (ADF11_all), intent(in) :: ad !< ADF11 datatype
real*8, intent(in) :: density !< initial log10 density in m^-3
real*8, intent(in) :: temperature !< initial log10 electron temperature in K
type (non_coronal) :: cor !< non_coronal equilibrium datatype
integer :: iz
cor%ad = ad
cor%n_Z0 = ad%n_Z+1
allocate(cor%fractions(cor%n_Z0),cor%coronal(cor%n_Z0),cor%Z(cor%n_Z0),cor%ion_rate(ad%n_Z),cor%rec_rate(ad%n_Z),cor%rad(ad%n_Z))
do iz=1,cor%n_Z0
cor%Z(iz) = real(iz,8)
enddo
cor%time = 0.d0
cor%fractions = 0.0d0
cor%fractions(1) = 1.0d0
cor%density = density
cor%temperature = temperature
call cor%update_GCRs()
end function non_coronal_equilibrium
! -------------------------------------------------------------------------------------
! --- Update Temperature
! -------------------------------------------------------------------------------------
subroutine update_T(cor,temperature)
class(non_coronal), intent(inout) :: cor !< Coronal equilibrium type
real*8, intent(in) :: temperature !< log10 temperature in m^-3
cor%temperature=temperature
call cor%update_GCRs()
end subroutine update_T