Commit Graph

305 Commits

Author SHA1 Message Date
Michele Guerini Rocco
2fed2ab5ec
src/gray_core.f90: remove unused variables in rhs 2023-09-21 14:21:25 +02:00
Michele Guerini Rocco
f75cedbf2b
src/gray_params.f90: fix comment 2023-09-21 14:21:25 +02:00
Michele Guerini Rocco
8bc5ac0064
always use generic math functions
This replaces double precision-specific function in order to allow
building GRAY with other real kinds, for example single or quadruple
precision.
2023-09-21 14:21:24 +02:00
Michele Guerini Rocco
dcc832ce65
fix simple limiter in analytic equilibrium
In the case of analytic equilibrium without a limiter contour, the
simple limiter was built incorrectly due to an unnecessary conversion
from cm (the equilibrium data are already in metre).
2023-09-20 16:15:41 +02:00
Michele Guerini Rocco
61605d3478
fix density calculation in analytical mode
In the analytical mode the density does not have a tail, so tail%end is
not initialised. The density is exactly zero at ψ≥1.
2023-09-20 16:14:22 +02:00
Michele Guerini Rocco
f5a983f926
src/ini_parser.f90: open file for reading 2023-09-20 16:14:22 +02:00
Michele Guerini Rocco
59dfcb7799
src/gray_cli.f90: allow enabling or disabling all units 2023-09-20 16:14:21 +02:00
Michele Guerini Rocco
8425e5e286
src/gray_cli.f90: simplify argument handling 2023-09-20 16:14:21 +02:00
Michele Guerini Rocco
a27e56933c
src/main.f90: give priority to cli over beamdata.txt 2023-09-20 16:14:21 +02:00
Michele Guerini Rocco
62c3045a7f
src/ini_parser.f90: avoid procedure pointer
In this case a normal procedure dummy argument works as well.
2023-09-20 16:14:21 +02:00
Michele Guerini Rocco
69367ae981
src/gray_core.f90: print profiles up to ψ_bnd 2023-09-20 16:14:20 +02:00
Michele Guerini Rocco
707dca1ab8
src/coreprofiles.f90: add some debug output 2023-09-14 11:26:57 +02:00
Michele Guerini Rocco
7ed76959d4
call exit on errors only in main 2023-09-14 11:26:56 +02:00
Michele Guerini Rocco
daf3d500af
use linear interpolation for monotonic data
The ρ_p/ρ_t mapping is 1:1, so the interpolation must always preserve
monotonicity, of which cubic splines generally make no guarantee.

Note: Linear interpolation does not provide even C¹ continuity, but
these data is not directly used in the numerical integration, so it
should be fine. Ideally this should be replaced with cubic splines
computed with the Fritsch–Carlson algorithm.
2023-09-14 11:26:56 +02:00
Michele Guerini Rocco
9bcad028b1
improve error handling in the gray_main routine
- rename errocodes → gray_errors

- restructure the errors into a `error_spec` type

- make the list of errors easily extensible

- rewrite the `print_errn`, `print_errhcd` (now `print_err_raytracing`,
  `print_err_ecrh_cd`) subroutine to handle arbitrary errors

- add functions to easily manipulate errors
  (`raise_error`, `has_error`, `is_critical`)

- remove print statements from quadpack

- log all errors to stderr using the logger module
2023-05-11 17:47:13 +02:00
Michele Guerini Rocco
78d8bdbb33
src/coreprofiles.f90: exit on density fit errors 2023-05-11 17:47:05 +02:00
Michele Guerini Rocco
b1accf0ae3
simplify handling of splines
This adds a new `splines` module which implements a high-level interface
for creating and evaluating splines and rewrite almost all modules to
use it. Also, notably:

1. both `simplespline` and DIERCKX splines can now used with a uniform
   interface

2. most complexity due to handling working space arrays is gone

3. memory management has been significantly simplified too
2023-04-12 23:45:49 +02:00
Michele Guerini Rocco
1261860f40
add some useful debug messages 2023-04-12 23:45:49 +02:00
Michele Guerini Rocco
cc889bb5a0
use the logger everywhere
This converts the last remaining warnings to use the logging system.
Also drops `catand` and replace it with the intrinsic `atan`, which
supports complex as well as real numbers.

Note: before 3eab989d the `catand` function was actually incorrent!
The definition of arctan(z) can be obtained starting from the identity

  d/dz arctan(z) = 1/(1 + z²) = ½ [1/(1 + iz) + 1/(1 - iz)],

integrating and using the definition log(z) = ∫₁^z dz/z,

  arctan(z) = -i/2 [log(1 + iz) - log(1 - iz)].

If log is the principal branch, log(z) = log|z| + i arg(z), then

  arctan(z) = -i/2 log(w) = 1/2 arg(w) -i/2 log|w|

where w = (1 + iz)/(1 - iz). Finally, the real part is

  Re arctan(z) = 1/2 atan2(2Re(z), 1 - |z|²).

The term -|z|² is missing from the `catand` definition of GRAY,
but is present in the original Fortran 77 code from [SLATEC]:
it has probably been lost in the translation.

[SLATEC]: https://people.math.sc.edu/Burkardt/f_src/slatec/slatec.f90
2023-04-12 23:45:49 +02:00
Michele Guerini Rocco
0a63a20e73
src/dispersion.f90: cleanup
- merge branch with a method to control the speed of iteration and
  improve the convergence of `warmdisp` (thanks Thomas)

- unify `diel_tens_fr` and `diel_tens_wr` into a single subroutine,
  `dielectric_tensor`

- stay as close as possible to the notation of Daniela Farina's paper

- make `sox` an integer

- mark more subroutines as pure

- add more comments
2023-04-12 23:45:49 +02:00
Michele Guerini Rocco
c7d0d8370c
src/gray_core.f90: make some {disp,plas}_deriv outputs optional
Some of the outputs of disp_deriv and plas_deriv are only needed
when updating the local plasma quantities (ywppla_upd) and not when
integrating the raytracing equations (rkstep).

This change save some unnecessary computations and variable definitions.

Also add some comments to disp_deriv
2023-04-12 23:44:38 +02:00
Michele Guerini Rocco
658389f586
src/multipass.f90: improve error wording 2023-04-12 23:44:38 +02:00
Michele Guerini Rocco
69308901ee
src/beams.f90: document read_beam{0,1} formats 2023-04-12 23:44:38 +02:00
Michele Guerini Rocco
038864a84f
src/gray_params.f90: remove unused variable 2023-04-12 23:44:37 +02:00
Michele Guerini Rocco
018fd8eea2
improve some comments 2023-04-12 23:44:37 +02:00
Michele Guerini Rocco
92f0cad3c1
depend: fix typo 2023-03-30 11:06:33 +02:00
Michele Guerini Rocco
f169db3a70
default.nix: update to Nixpkgs 21.11 2023-03-29 21:52:21 +02:00
e6d864e63b Fix the summation mode + temporary fix for file unit numbers
- Add missing array allocations
- Add parameter for varying number of columns in input files
- Change output unit numbers (dirty fix. Original units created an empty
  named file, but wrote in default named fort.* files)
2022-11-24 23:37:29 +01:00
411c4ece48 Fix problem with long filenames not fitting the header width 2022-11-24 23:34:09 +01:00
aa3b816ffe Update license 2022-11-18 19:47:50 +01:00
43de968b46 Add License files 2022-11-17 19:42:44 +01:00
10dc3ba3d0 Improve documentation build
- Documentation is not built anymore with the default `all` rule to
improve portability. It must be built explicitly with `make docs`.
- Font types are not specified to allow building on systems with a
restricted set of fonts.
- Syntax fixes in the documentation Markdown.
2022-11-17 19:31:58 +01:00
ddfc5db039 Add -fPIC flag to compile successfully on some systems 2022-11-14 18:23:20 +00:00
5ff1d8cd10 Replace str_index function with intrinsic index 2022-11-14 16:57:57 +00:00
91fa6d84e0 Add first draft of Python plotting script 2022-11-13 01:57:09 +01:00
6181b6096e Fix Makefile to remove literal '\n' printed in .d files in some systems. 2022-10-28 13:32:56 +02:00
3eab989d7b Fix bug in catand (complex arc tangent)
Function catand returned an incorrect value for its real part. To be
possibly replaced with the intrinsic function atan.
2022-10-04 19:05:43 +02:00
8c3e246f25 Add missing iprof parameter initialization in GRAY/JINTRAC interface
Cherry-pick from commit 6627cb14
2022-10-04 18:43:13 +02:00
Michele Guerini Rocco
8f90cb21da
gray_jetto1beam: activate some debug units by defaults 2022-09-27 18:44:32 +02:00
Michele Guerini Rocco
df4930818f
Makefile: add JETTO-specific target 2022-09-27 18:44:32 +02:00
Michele Guerini Rocco
45ef9c5eae
src/coreprofiles: make psnbnd fully automatic
1. Fix the mismatch between the psnbnd in coreprofiles and gray_core.
   This happens whenever gray overrides the externally provided one
   (i.e. the density tail would become negative before psnbnd and is so
   rescaled to end exactly on the zero).

2. Make psnbnd no longer required by always computing it as in 1.
   It hasn't been removed, because gray_params.data is sacrosant,
   but it no longer has any effect.

3. Cleanup: mark public functions, restructure the global variables into
   three categories; add comments explaining the analytical profiles
   format, formulae and how the polynomial tail is computed.
2022-05-22 04:06:21 +02:00
Michele Guerini Rocco
63e2bf0b04
convert remaining subroutines to derived types
- converts analytical profiles/equilibrium subroutines to derived types
- use less undecipherable and consistent names

The subroutine names have changed as follows:

    set_prfspl → set_profiles_spline
    set_prfan  → set_profiles_an
  unset_prfspl → unset_profiles_spline
  unset_prfan  → unset_profiles_an
  set_equian   → set_equil_an
  set_eqspl    → set_equil_spline
  unset_equian → unset_equil_an
  unset_eqspl  → unset_equil_spline
  unset_rhospl → unset_rho_spline
2022-05-22 01:18:08 +02:00
Michele Guerini Rocco
9fcf8e51e8
doc/3.io-files.md: clarify ieccd options 2022-05-22 01:02:19 +02:00
Michele Guerini Rocco
ebbea7cbeb
doc/2.physics.md: fix eq reference 2022-05-22 01:02:19 +02:00
Michele Guerini Rocco
f5ab40f54f
src/gray_core.f90: cleanup
- add some comments
- annotate loops
- indent comments
- remove trailing whitespace
- reduce usage of opaque global variables
- use Fortran 90 logical operators
- use Fortran 2003 array syntax
2022-05-22 01:02:19 +02:00
Michele Guerini Rocco
6010a9361b
add INI configuration file
This adds a new configuration file based on the INI format.
The new format will allow adding GRAY parameters without breaking
compatibility with existing configurations, unlike as of the old
gray_params.data.
2022-05-22 01:02:19 +02:00
Michele Guerini Rocco
0a1a0b5ac8
src/gray_core.f90: use intrinsic linear algebra functions 2022-05-19 19:00:55 +02:00
Michele Guerini Rocco
0cf1ab2e8d
src/dispersion.f90: mark colddisp a pure function 2022-05-19 19:00:54 +02:00
Michele Guerini Rocco
3cee84690c
src/dispersion.f90: mark zetac as pure 2022-05-11 01:15:08 +02:00
Michele Guerini Rocco
c3f8cb1921
default.nix: update to Nixpkgs 21.11 2022-05-11 01:15:08 +02:00