krn_simulation_m Module

Step management and interpolation in time


Uses

  • module~~krn_simulation_m~~UsesGraph module~krn_simulation_m krn_simulation_m fortran_yaml_c fortran_yaml_c module~krn_simulation_m->fortran_yaml_c module~krn_global_tools_m krn_global_tools_m module~krn_simulation_m->module~krn_global_tools_m module~lib_hdf_write_m lib_hdf_write_m module~krn_simulation_m->module~lib_hdf_write_m module~lib_input_m lib_input_m module~krn_simulation_m->module~lib_input_m ieee_arithmetic ieee_arithmetic module~krn_global_tools_m->ieee_arithmetic iso_c_binding iso_c_binding module~krn_global_tools_m->iso_c_binding iso_fortran_env iso_fortran_env module~krn_global_tools_m->iso_fortran_env module~lib_hdf_write_m->module~krn_global_tools_m module~lib_hdf_write_m->module~lib_input_m h5ds h5ds module~lib_hdf_write_m->h5ds h5lt h5lt module~lib_hdf_write_m->h5lt hdf5 hdf5 module~lib_hdf_write_m->hdf5 module~lib_hdf_write_m->iso_c_binding module~lib_input_m->fortran_yaml_c module~lib_input_m->module~krn_global_tools_m module~lib_input_m->h5lt module~lib_input_m->hdf5

Used by

  • module~~krn_simulation_m~~UsedByGraph module~krn_simulation_m krn_simulation_m module~cmp_boundary_init_m cmp_boundary_init_m module~cmp_boundary_init_m->module~krn_simulation_m module~lib_he_thermo_m lib_He_thermo_m module~cmp_boundary_init_m->module~lib_he_thermo_m module~cmp_channel_calc_m cmp_channel_calc_m module~cmp_channel_calc_m->module~krn_simulation_m module~cmp_channel_init_m cmp_channel_init_m module~cmp_channel_calc_m->module~cmp_channel_init_m module~cmp_channel_source_terms_m cmp_channel_source_terms_m module~cmp_channel_calc_m->module~cmp_channel_source_terms_m module~cmp_channel_init_m->module~krn_simulation_m module~cmp_channel_init_m->module~lib_he_thermo_m module~cmp_circulator_init_m cmp_circulator_init_m module~cmp_circulator_init_m->module~krn_simulation_m module~cmp_circulator_init_m->module~lib_he_thermo_m module~cmp_ffsrclink_init_m cmp_FFsrcLink_init_m module~cmp_ffsrclink_init_m->module~krn_simulation_m module~cmp_junction_init_m cmp_junction_init_m module~cmp_junction_init_m->module~krn_simulation_m module~cmp_junction_init_m->module~lib_he_thermo_m module~cmp_mesh2d_calc_m cmp_mesh2D_calc_m module~cmp_mesh2d_calc_m->module~krn_simulation_m module~cmp_mesh2d_init_m cmp_mesh2D_init_m module~cmp_mesh2d_calc_m->module~cmp_mesh2d_init_m module~cmp_mesh2d_init_m->module~krn_simulation_m module~cmp_solid_calc_m cmp_solid_calc_m module~cmp_solid_calc_m->module~krn_simulation_m module~cmp_solid_init_m cmp_solid_init_m module~cmp_solid_calc_m->module~cmp_solid_init_m module~cmp_solid_init_m->module~krn_simulation_m module~cmp_strand_init_m cmp_strand_init_m module~cmp_strand_init_m->module~krn_simulation_m module~krn_linear_system_m krn_linear_system_m module~krn_linear_system_m->module~krn_simulation_m module~lib_he_thermo_m->module~krn_simulation_m program~reims_p reims_p program~reims_p->module~krn_simulation_m program~reims_p->module~cmp_channel_calc_m program~reims_p->module~cmp_mesh2d_calc_m program~reims_p->module~cmp_solid_calc_m program~reims_p->module~krn_linear_system_m module~cmp_boundary_calc_m cmp_boundary_calc_m program~reims_p->module~cmp_boundary_calc_m module~cmp_channel_flux_m cmp_channel_flux_m program~reims_p->module~cmp_channel_flux_m module~cmp_circulator_calc_m cmp_circulator_calc_m program~reims_p->module~cmp_circulator_calc_m module~cmp_ffsrclink_calc_m cmp_FFsrcLink_calc_m program~reims_p->module~cmp_ffsrclink_calc_m module~cmp_junction_calc_m cmp_junction_calc_m program~reims_p->module~cmp_junction_calc_m module~cmp_mesh2d_flux_m cmp_mesh2D_flux_m program~reims_p->module~cmp_mesh2d_flux_m module~cmp_mesh2d_hdf5_write_m cmp_mesh2D_hdf5_write_m program~reims_p->module~cmp_mesh2d_hdf5_write_m module~cmp_solid_flux_m cmp_solid_flux_m program~reims_p->module~cmp_solid_flux_m module~cmp_strand_calc_m cmp_strand_calc_m program~reims_p->module~cmp_strand_calc_m module~cmp_strand_flux_m cmp_strand_flux_m program~reims_p->module~cmp_strand_flux_m module~cmp_boundary_calc_m->module~cmp_boundary_init_m module~cmp_boundary_calc_m->module~lib_he_thermo_m module~cmp_channel_flux_m->module~cmp_channel_init_m module~cmp_channel_flux_m->module~lib_he_thermo_m module~cmp_channel_source_terms_m->module~cmp_channel_init_m module~cmp_channel_source_terms_m->module~lib_he_thermo_m module~cmp_circulator_calc_m->module~cmp_circulator_init_m module~cmp_ffsrclink_calc_m->module~cmp_ffsrclink_init_m module~cmp_ffsrclink_calc_m->module~lib_he_thermo_m module~cmp_junction_calc_m->module~cmp_junction_init_m module~cmp_junction_calc_m->module~lib_he_thermo_m module~cmp_mesh2d_flux_m->module~cmp_mesh2d_init_m module~cmp_mesh2d_hdf5_write_m->module~cmp_mesh2d_init_m module~cmp_solid_flux_m->module~cmp_solid_init_m module~cmp_strand_calc_m->module~cmp_strand_init_m module~cmp_strand_source_terms_m cmp_strand_source_terms_m module~cmp_strand_calc_m->module~cmp_strand_source_terms_m module~cmp_strand_flux_m->module~cmp_strand_init_m module~cmp_strand_source_terms_m->module~cmp_strand_init_m

Variables

Type Visibility Attributes Name Initial
type(hdf5_t), public :: h5
integer, public :: sim_error = 0
integer, public, parameter :: MAX_SIM_ERRORS = 10
character(len=512), public :: sim_error_msg(MAX_SIM_ERRORS)
type(h5_export_c_t), private, save, target :: H
type(tbl_dsc_c_t), private, allocatable, target, save :: Tbls_c(:)
type(comp_desc_c_t), private, allocatable, target, save :: Comps_c(:)
character(kind=c_char, len=1), private, allocatable, target, save :: vars_buf(:)
integer(kind=c_int), private, allocatable, save :: vars_offset(:)
integer(kind=c_int), private, allocatable, save :: n_vars_tbl(:)
integer(kind=c_int), private, allocatable, save :: var_len_tbl(:)

Abstract Interfaces

abstract interface

  • private function init_signal_ext_if(fct_ptr_to_ext, cfg_len, cfg_str, c_pt, sign_ptr, n) bind(C)

    Arguments

    Type IntentOptional Attributes Name
    type(c_funptr), value :: fct_ptr_to_ext
    integer(kind=c_int), value :: cfg_len
    character(len=*) :: cfg_str
    type(c_ptr) :: c_pt
    type(c_funptr) :: sign_ptr
    integer(kind=c_int), value :: n

    Return Value logical

abstract interface

  • private subroutine itf_signal(c_pt, time, signal) bind(C)

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), value :: c_pt
    real(kind=c_double), value :: time
    real(kind=c_double) :: signal(*)

Derived Types

type, public ::  signal_t

Components

Type Visibility Attributes Name Initial
real(kind=dp), public, allocatable :: time(:)

time events (points of interpolation)

real(kind=dp), public, allocatable :: offset(:,:)

offset values (points of interpolation)

real(kind=dp), public, allocatable :: gain(:,:)

gain values for 0th order simply 1

real(kind=dp), public, allocatable :: x(:)

spatial coordinates

integer, public :: i = 1

last index (starting point for iteration)

type(simulation_t), public, pointer :: sim
type(c_funptr), public :: init_signal_ext_ptr = C_NULL_FUNPTR
character(len=:), public, allocatable :: cfg_str
type(c_funptr), public :: sign_ptr = C_NULL_FUNPTR
type(c_ptr), public :: val_cfg = C_NULL_PTR
procedure(itf_signal), public, pointer, nopass :: val_fpt => null()
procedure(init_signal_ext_if), public, pointer, nopass :: init_signal_ext => null()

Type-Bound Procedures

procedure, public :: init => signal_init
procedure, public :: v1d => signal_v1d
procedure, public :: v0d => signal_v0d

type, public ::  simulation_t

Components

Type Visibility Attributes Name Initial
real(kind=dp), public :: t = 0

current simulation time

real(kind=dp), public :: dt

current time step

logical, public :: explicit = .true.

true for explicit, false for implicit scheme

logical, public :: rejected = .false.

current step is rejected

logical, public :: rollback = .false.

rollback in progress, skip state advance

logical, public :: in_recovery = .false.

error recovery explicit steps in progress

integer, public :: recovery_steps_left = 0

countdown for recovery explicit steps

integer, public :: consecutive_rollbacks = 0

number of consecutive rollbacks without a successful step

real(kind=dp), public :: dtPrev1

previous time step

real(kind=dp), public :: dtPrev2

time step 2 steps before

real(kind=dp), public :: dtPrev3

time step 3 steps before

real(kind=dp), public :: dtPrev4

time step 4 steps before

real(kind=dp), public :: dtPrev5

time step 5 steps before

real(kind=dp), public :: dt_exp

explicit time step (save for calc)

type(signal_t), public :: impl_tol

from input file implicit tolerance

real(kind=dP), public :: expl_tol

from input file explicit tolerance

real(kind=dP), public :: kValue

from input file step management filter gain

real(kind=dP), public :: max_step

from input file maximum step that solver can take

real(kind=dP), public :: t_final

from input file time to simulate

real(kind=dp), public :: c0

step controller memory

integer, public :: step = 0

all steps including rejected

integer, public :: expl_steps = 10

Minimum number of explicit steps left

real(kind=dp), public, allocatable :: events_time(:)

list of time events forcing step

logical, public, allocatable :: events_expl(:)

list of time events forcing explicit

real(kind=dp), public :: scheme_diff_fact

factor to be applied to the acoustic speed estimate

Type-Bound Procedures

procedure, public :: init => sim_init
procedure, public :: update_exp_dt => sim_update_exp_dt
procedure, public :: step_management => sim_step_management

type, private, bind(C) ::  comp_desc_c_t

Components

Type Visibility Attributes Name Initial
type(c_ptr), public :: name_ptr
integer(kind=c_int), public :: name_len
type(c_ptr), public :: node_x_ptr
integer(kind=c_int), public :: n_node
type(c_ptr), public :: data_ptr
integer(kind=c_int), public :: n1
integer(kind=c_int), public :: n2

type, private, bind(C) ::  tbl_dsc_c_t

Components

Type Visibility Attributes Name Initial
type(c_ptr), public :: name_ptr
integer(kind=c_int), public :: name_len
type(c_ptr), public :: vars_ptr
integer(kind=c_int), public :: n_vars
integer(kind=c_int), public :: var_len
type(c_ptr), public :: comps_ptr
integer(kind=c_int), public :: n_comps

type, private, bind(C) ::  h5_export_c_t

Components

Type Visibility Attributes Name Initial
integer(kind=c_int), public :: nb_tables
type(c_ptr), public :: tables_ptr

Functions

private function s_to_str(val) result(str_out)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: val

Return Value character(len=5)

private function filter(simple, c1l, c0l, kl)

Filter/controller with limiter used by step management

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: simple

True: Elementary filter, False: PI42 controller

real(kind=dp), intent(in) :: c1l
real(kind=dp), intent(in) :: c0l
real(kind=dp), intent(in) :: kl

Return Value real(kind=dp)

private function signal_v1d(me) result(val)

Arguments

Type IntentOptional Attributes Name
class(signal_t), intent(inout) :: me

Return Value real(kind=dp), (size(me%x))

interpolated value

private function signal_v0d(me) result(val)

Arguments

Type IntentOptional Attributes Name
class(signal_t), intent(inout) :: me

Return Value real(kind=dp)

interpolated value


Subroutines

private subroutine sim_init(me, input)

Arguments

Type IntentOptional Attributes Name
class(simulation_t), intent(inout) :: me
type(input_t), intent(in) :: input

private subroutine sim_update_exp_dt(me, wave_time)

Arguments

Type IntentOptional Attributes Name
class(simulation_t), intent(inout) :: me
real(kind=dp), intent(in) :: wave_time

private subroutine sim_step_management(me, err)

Arguments

Type IntentOptional Attributes Name
class(simulation_t), intent(inout) :: me
real(kind=dp), intent(in) :: err

public subroutine set_error(msg)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: msg

private subroutine sim_print(me)

Arguments

Type IntentOptional Attributes Name
type(simulation_t), intent(in) :: me

private subroutine make_c_string(txt, buf, pos, ptr, len_out)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: txt
character(kind=c_char, len=1), intent(inout), target :: buf(:)
integer, intent(inout) :: pos
type(c_ptr), intent(out) :: ptr
integer(kind=c_int), intent(out) :: len_out

private subroutine expose_state_to_ext_library(h5_ptr) bind(C)

Arguments

Type IntentOptional Attributes Name
type(c_ptr) :: h5_ptr

private subroutine signal_init(me, sim, input_cfg, key, x)

Arguments

Type IntentOptional Attributes Name
class(signal_t), intent(inout) :: me
type(simulation_t), intent(inout), target :: sim
type(input_t), intent(in) :: input_cfg
character(len=*), intent(in) :: key
real(kind=dp), intent(in), optional :: x(:)

private subroutine interpolate(x, y, x_out, y_out)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: x(:)
real(kind=dp), intent(in) :: y(:)
real(kind=dp), intent(in) :: x_out
real(kind=dp), intent(out) :: y_out

private subroutine interpolate_vector(x, y, x_out, y_out)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: x(:)
real(kind=dp), intent(in) :: y(:)
real(kind=dp), intent(in) :: x_out(:)
real(kind=dp), intent(out) :: y_out(:)

private subroutine merge_events(time_inout, expl_inout, time, explicit)

Merging sorted events of simulation

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout), allocatable :: time_inout(:)
logical, intent(inout), allocatable :: expl_inout(:)
real(kind=dp), intent(in) :: time(:)

sorted, without duplicates input arrays ending with huge

logical, intent(in) :: explicit