apm Submodule

This SUBMODULE contains the implementation of the method perform_apm of TYPE particles.

FT 04.06.2021



Uses

  • module~~apm~~UsesGraph module~apm apm constants constants module~apm->constants module~sph_particles sph_particles module~apm->module~sph_particles module~utility utility module~apm->module~utility module~sph_particles->module~utility module~id_base id_base module~sph_particles->module~id_base timing timing module~sph_particles->timing module~utility->constants matrix matrix module~utility->matrix module~id_base->module~utility module~id_base->timing

Contents


Module Procedures

module procedure perform_apm module subroutine perform_apm(get_density, get_nstar_id, get_pressure_id, compute_pressure, npart_output, pos_input, pvol, h_output, nu_output, center, com_star, mass, sizes, eqos, apm_max_it, max_inc, mass_it, correct_nu, nuratio_thres, nuratio_des, use_pressure, adapt_ghosts, move_away_ghosts, nx_gh, ny_gh, nz_gh, ghost_dist, use_atmosphere, remove_atmosphere, print_step, namefile_pos_id, namefile_pos, namefile_results, validate_position, surf)

Compute the particle positions as follows:

Read more…

Arguments

Type IntentOptional Attributes Name
function get_density(x, y, z) result(density)

Returns the baryon mass density at the desired point

Arguments
Type IntentOptional Attributes Name
double precision, intent(in) :: x

coordinate of the desired point

double precision, intent(in) :: y

coordinate of the desired point

double precision, intent(in) :: z

coordinate of the desired point

Return Value double precision

Baryon mass density at

subroutine get_nstar_id(npart, x, y, z, nstar_sph, nstar_id, nlrf_sph, sqg)

Computes the proper baryon number density at the particle positions

Arguments
Type IntentOptional Attributes Name
integer, intent(in) :: npart

Number of real particles (i.e., no ghost particles included here)

double precision, intent(in) :: x(npart)

Array of coordinates

double precision, intent(in) :: y(npart)

Array of coordinates

double precision, intent(in) :: z(npart)

Array of coordinates

double precision, intent(in) :: nstar_sph(npart)

\(\mathrm{SPH}\) proper baryon density

double precision, intent(out) :: nstar_id(npart)

Array to store the computed proper baryon number density

double precision, intent(out) :: nlrf_sph(npart)

Array to store the local rest frame baryon density computed from the \(\mathrm{SPH}\) proper baryon density

double precision, intent(out) :: sqg(npart)

Square root of minus the determinant of the spacetime metric

function get_pressure_id(x, y, z) result(pressure)

Returns the baryon mass density at the desired point

Arguments
Type IntentOptional Attributes Name
double precision, intent(in) :: x

coordinate of the desired point

double precision, intent(in) :: y

coordinate of the desired point

double precision, intent(in) :: z

coordinate of the desired point

Return Value double precision

Baryon mass density at

subroutine compute_pressure(npart, x, y, z, nlrf, eqos, pressure, verbose)
Arguments
Type IntentOptional Attributes Name
integer, intent(in) :: npart

Returns the baryon mass density at the desired point

double precision, intent(in) :: x(npart)

coordinate of the desired point

double precision, intent(in) :: y(npart)

coordinate of the desired point

double precision, intent(in) :: z(npart)

coordinate of the desired point

double precision, intent(in) :: nlrf(npart)

Baryon mass density in the local rest frame

type(eos), intent(in) :: eqos

\(\mathrm{EOS}\) to use

double precision, intent(inout) :: pressure(npart)

Baryon mass density at

logical, intent(in), optional :: verbose

If .TRUE., print informative standard output about how the pressure is computed. Default is .TRUE.

integer, intent(inout) :: npart_output

Initial particle number

double precision, intent(inout), DIMENSION(:,:), ALLOCATABLE :: pos_input

Initial particle positions

double precision, intent(inout), DIMENSION(:), ALLOCATABLE :: pvol

Initial particle volume

double precision, intent(inout), DIMENSION(:), ALLOCATABLE :: h_output

Array to store the smoothing lengths computed at the end of the APM iteration

double precision, intent(inout), DIMENSION(:), ALLOCATABLE :: nu_output

Array to store the baryon number per particle computed at the end of the APM iteration

double precision, intent(in), DIMENSION(3) :: center

Center of the matter object, from the \(\mathrm{ID}\)

double precision, intent(inout), DIMENSION(3) :: com_star

Center of mass of the matter object, from the \(\mathrm{ID}\)

double precision, intent(in) :: mass

Mass of the matter object

double precision, intent(in), DIMENSION(6) :: sizes

Sizes of the matter object

type(eos), intent(in) :: eqos

\(\mathrm{EOS}\) to use when computing the pressure

integer, intent(in) :: apm_max_it

Maximum number of APM iterations, irrespective of the EXIT condition

integer, intent(in) :: max_inc

Sets the EXIT condition: If the average over all the particles of the relative error in the density estimate grows max_inc times, exit the iteration.

logical, intent(in) :: mass_it

If .TRUE. performs a second iteration after the APM one, without moving the particles, changing their mass in order to better match the star density. The mass ratio grows very fast in all the tried experiments, hence the suggested value is .FALSE.

logical, intent(in) :: correct_nu

If .TRUE., the baryon number per particle nu is corrected to include the total baryonic masses of the stars.

double precision, intent(in) :: nuratio_thres

Maximum mass ratio (equivalently baryon number ratio) to be used in the one-time-only final correction of the particle masses to match the star density even better (without moving the particles)

double precision, intent(in) :: nuratio_des

Sets the EXIT condition: If the baryon number ratio is within 2.5% of nuratio_des, exit the iteration Set nuratio_des to 0 to deactivate and exit the APM iteration using max_inc

logical, intent(in) :: use_pressure

If .TRUE., uses the physical pressure computed with the \(\mathrm{EOS}\) using the SPH estimate of the density nlrf_sph, to compute the artificial pressure. Otherwise, the density variable nstar_sph is used to compute the artificial pressure

logical, intent(in) :: adapt_ghosts

If .TRUE., the ghost particles will be placed and have a baryon number such to reproduce the density of the outermost layers (r > 99% of the minimum radius) of the object. If .TRUE., the arguments nx_gh, ny_gh, nz_gh, ghost_dist are ignored; if .FALSE., they are instead used to place the ghost particles

logical, intent(in) :: move_away_ghosts

If .TRUE., the ghost particles will slowly move away from the surface of the star during the iteration (depending on the EXIT condition chosen, this happens in slightly different ways), to allow for the real particles to get closer to the surface

integer, intent(in) :: nx_gh

Number of lattice points in the x direction for ghosts

integer, intent(in) :: ny_gh

Number of lattice points in the y direction for ghosts

integer, intent(in) :: nz_gh

Number of lattice points in the z direction for ghosts

double precision, intent(inout) :: ghost_dist

Distance between the ghost particles and the surface of the matter object considered (star, ejecta, etc...)

logical, intent(inout) :: use_atmosphere

If .TRUE., allows particles to move where the density is 0, and displace them using only the smoothing term. This can be useful when the system has an irregular geometry, as, for example, an ejecta; .FALSE. otherwise

logical, intent(inout) :: remove_atmosphere

If .TRUE., removes the particles placed where the density is 0, at the end of the APM iteration; .FALSE. otherwise

integer, intent(inout) :: print_step

Prints the particle positions to a formatted file every print_step steps

character(len=*), intent(inout), optional :: namefile_pos_id

Name for the formatted file where the initial particle positions and the ghost positions will be printed

character(len=*), intent(inout), optional :: namefile_pos

Name for the formatted file where the particle positions and the ghost positions will be printed every 15 iterations

character(len=*), intent(inout), optional :: namefile_results

Name for the formatted file where various quantities related to the particle distribution, the baryon number particle and the kernel estimate of the density will be printed at the end of the APM iteration

procedure(validate_position_int), optional :: validate_position

Returns 1 if the position is not valid, 0 otherwise

type(surface), intent(in), optional :: surf

Surface of the matter object