Compute the particle positions as follows:
After this procedure, the resulting particle distribution has positions and baryon numbers that kernel-estimate very well the mass density of the star, and has a low mass ratio.
This procedure assigns positions, smoothing lengths , and .
FT 04.06.2021
$OMP REDUCTION( MAX: radius_part ) &
Type | Intent | Optional | Attributes | Name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
function get_density(x, y, z) result(density)Returns the baryon mass density at the desired point Arguments
Return Value double precisionBaryon 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
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
function get_pressure_id(x, y, z) result(pressure)Returns the baryon mass density at the desired point Arguments
Return Value double precisionBaryon mass density at |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
subroutine compute_pressure(npart, x, y, z, nlrf, eqos, pressure, verbose)Arguments
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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; |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logical, | intent(inout) | :: | remove_atmosphere |
If .TRUE., removes the particles placed where the density is 0,
at the end of the APM iteration; |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | private | :: | a | ||||
integer, | private | :: | a_numax | ||||
integer, | private | :: | a_numax2 | ||||
integer, | private | :: | a_numin | ||||
integer, | private | :: | a_numin2 | ||||
double precision, | private, | DIMENSION(:,:), ALLOCATABLE | :: | all_pos | |||
double precision, | private, | DIMENSION(:,:), ALLOCATABLE | :: | all_pos_prev | |||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | art_pr | |||
double precision, | private | :: | art_pr_max | ||||
double precision, | private | :: | atmosphere_density | ||||
double precision, | private | :: | average_displacement | ||||
integer, | private | :: | b | ||||
integer, | private | :: | cnt1 | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | cnt_array | |||
integer, | private, | DIMENSION(:), ALLOCATABLE | :: | cnt_move | |||
integer, | private | :: | cnt_push_ghost | ||||
double precision, | private | :: | com_d | ||||
double precision, | private | :: | com_x | ||||
double precision, | private | :: | com_y | ||||
double precision, | private | :: | com_z | ||||
double precision, | private, | DIMENSION(:,:), ALLOCATABLE | :: | correction_pos | |||
double precision, | private | :: | dN | ||||
double precision, | private | :: | dN_av | ||||
double precision, | private | :: | dN_max | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | dNstar | |||
double precision, | private, | DIMENSION(:,:), ALLOCATABLE | :: | dS | |||
double precision, | private | :: | dS_norm_av | ||||
logical, | private, | parameter | :: | debug | = | .FALSE. | |
double precision, | private | :: | dens_min | ||||
integer, | private | :: | dim_seed | ||||
double precision, | private | :: | dx | ||||
double precision, | private | :: | dy | ||||
double precision, | private | :: | dz | ||||
double precision, | private | :: | ellipse_thickness | ||||
double precision, | private | :: | err_N_max | ||||
double precision, | private | :: | err_N_mean | ||||
double precision, | private | :: | err_N_mean_min | ||||
double precision, | private | :: | err_N_mean_min_old | ||||
double precision, | private | :: | err_mean_old | ||||
double precision, | private | :: | err_n_min | ||||
logical, | private | :: | exist | ||||
character(len=:), | private, | ALLOCATABLE | :: | finalnamefile | |||
type(timer), | private | :: | find_h_bruteforce_timer | ||||
double precision, | private | :: | frac | ||||
double precision, | private | :: | ghost_displacement | ||||
double precision, | private, | DIMENSION(:,:), ALLOCATABLE | :: | ghost_pos | |||
double precision, | private | :: | h_av | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | h_guess | |||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | h_guess_tmp | |||
double precision, | private | :: | h_max | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | h_tmp | |||
integer, | private | :: | i | ||||
integer, | private | :: | i_shell | ||||
integer, | private | :: | ill | ||||
integer, | private | :: | inde | ||||
integer, | private | :: | index1 | ||||
integer, | private | :: | itot | ||||
integer, | private | :: | itr | ||||
integer, | private | :: | itr2 | ||||
integer, | private | :: | j | ||||
integer, | private | :: | k | ||||
integer, | private | :: | l | ||||
double precision, | private | :: | l2norm_displacement | ||||
integer, | private, | parameter | :: | m_max_it | = | 50 | |
double precision, | private, | parameter | :: | max_art_pr_ghost | = | 1.0D+10 | |
integer, | private, | parameter | :: | max_npart | = | 20D+6 | |
double precision, | private | :: | max_nu | ||||
double precision, | private | :: | max_nu2 | ||||
integer, | private | :: | max_push_ghost | ||||
double precision, | private | :: | max_radius | ||||
double precision, | private | :: | max_z_real | ||||
double precision, | private | :: | mean_nu | ||||
double precision, | private | :: | min_nu | ||||
double precision, | private | :: | min_nu2 | ||||
double precision, | private | :: | min_radius | ||||
integer, | private | :: | n_inc | ||||
integer, | private, | DIMENSION(:), ALLOCATABLE | :: | n_neighbors | |||
integer, | private | :: | n_problematic_h | ||||
double precision, | private, | DIMENSION(:,:), ALLOCATABLE | :: | nearest_neighbors | |||
integer, | private, | DIMENSION(:), ALLOCATABLE | :: | neighbors_lists | |||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | nlrf_id | |||
double precision, | private | :: | nlrf_id_av | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | nlrf_sph | |||
integer, | private, | parameter | :: | nn_des | = | 301 | |
integer, | private | :: | npart_all | ||||
integer, | private | :: | npart_ghost | ||||
integer, | private | :: | npart_real | ||||
integer, | private | :: | npart_real_half | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | nstar_id | |||
double precision, | private | :: | nstar_id_av | ||||
double precision, | private | :: | nstar_id_err | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | nstar_int | |||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | nstar_sph | |||
double precision, | private | :: | nstar_sph_av | ||||
double precision, | private | :: | nstar_sph_err | ||||
double precision, | private | :: | nu_all | ||||
double precision, | private | :: | nu_ghost | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | nu_one | |||
double precision, | private | :: | nu_ratio | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | nu_tmp | |||
double precision, | private | :: | nu_tmp2 | ||||
double precision, | private | :: | nu_tot | ||||
integer, | private | :: | nuratio_cnt | ||||
integer, | private, | parameter | :: | nuratio_max_steps | = | 300 | |
integer, | private, | parameter | :: | nuratio_min_it | = | 100 | |
double precision, | private | :: | nuratio_tmp | ||||
double precision, | private | :: | nuratio_tmp_prev | ||||
double precision, | private, | parameter | :: | nuratio_tol | = | 2.5D-3 | |
integer, | private | :: | nx | ||||
integer, | private | :: | ny | ||||
integer, | private | :: | nz | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | particle_density_final | |||
double precision, | private | :: | phi | ||||
double precision, | private | :: | phi_ell | ||||
double precision, | private, | DIMENSION(:,:), ALLOCATABLE | :: | pos | |||
double precision, | private, | DIMENSION(3) | :: | pos_corr_tmp | |||
double precision, | private, | DIMENSION(3) | :: | pos_maxerr | |||
double precision, | private, | DIMENSION(:,:), ALLOCATABLE | :: | pos_tmp | |||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | pressure_id | |||
double precision, | private | :: | pressure_id_av | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | pressure_sph | |||
logical, | private | :: | push_away_ghosts | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | pvol_tmp | |||
double precision, | private | :: | r | ||||
double precision, | private | :: | r_ell | ||||
double precision, | private | :: | rad_x | ||||
double precision, | private | :: | rad_y | ||||
double precision, | private | :: | rad_z | ||||
double precision, | private | :: | radius_part | ||||
double precision, | private | :: | radius_x | ||||
double precision, | private | :: | radius_y | ||||
double precision, | private | :: | radius_z | ||||
double precision, | private | :: | rand_num | ||||
double precision, | private | :: | rand_num2 | ||||
integer, | private | :: | rel_sign | ||||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | rho_tmp | |||
integer, | private, | parameter | :: | search_pos | = | 10 | |
integer, | private, | DIMENSION(:), ALLOCATABLE | :: | seed | |||
double precision, | private, | DIMENSION(:), ALLOCATABLE | :: | sqg | |||
double precision, | private | :: | stddev_dN | ||||
double precision, | private | :: | stddev_nu | ||||
double precision, | private | :: | theta | ||||
double precision, | private | :: | theta_ell | ||||
double precision, | private, | parameter | :: | tiny_real | = | 1.0D-10 | |
double precision, | private | :: | tmp | ||||
double precision, | private, | parameter | :: | tol | = | 1.0D-3 | |
double precision, | private | :: | variance_dN | ||||
double precision, | private | :: | variance_nu | ||||
double precision, | private | :: | x_ell | ||||
double precision, | private | :: | xmax | ||||
double precision, | private | :: | xmin | ||||
double precision, | private | :: | xtemp | ||||
double precision, | private | :: | y_ell | ||||
double precision, | private | :: | ymax | ||||
double precision, | private | :: | ymin | ||||
double precision, | private | :: | ytemp | ||||
double precision, | private | :: | z_ell | ||||
double precision, | private | :: | zmax | ||||
double precision, | private | :: | zmin | ||||
double precision, | private | :: | ztemp |
Returns validate_position( x, y, z ) if the latter is present, 0 otherwise
FT 22.09.2021
Type | Intent | Optional | 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 |
validate_position( x, y, z ) if the latter is present, 0 otherwise
Allocate the fields used during the APM iteration
FT 20.04.2022
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | npart_real | |||
integer, | intent(in) | :: | npart_ghost |
Compute the \(\mathrm{SPH}\) canonical momentum
FT 17.06.2022
To be checked. Deprecated?
Remove the atmosphere
FT 20.04.2022
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout) | :: | npart_real |
Print the positions of the real and ghost particles to a formatted file
FT 20.04.2022
Return various densities and the determinant of the metric, needed in the APM iteration
FT 5.12.2021
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | npart_real |
Number of real particles (i.e., no ghost particles included here) |
||
double precision, | intent(in) | :: | x(npart_real) |
Array of coordinates |
||
double precision, | intent(in) | :: | y(npart_real) |
Array of coordinates |
||
double precision, | intent(in) | :: | z(npart_real) |
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 sacetime metric DOUBLE PRECISION, INTENT(OUT):: nstar_eul_id(npart_real) Array to store the computed proper baryon number density seen by the Eulerian observer |
||
logical, | intent(in) | :: | use_atmosphere |
|
Place ghost particles around the matter object, and print their positions together with the positions of the real particles to a formatted file
FT 20.04.2022
Return the pressure providd by the \(\mathrm{ID}\) (not the one computed from the \(\mathrm{SPH}\) density), needed in the APM iteration
FT 6.12.2022
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | npart_real |
Number of real particles (i.e., no ghost particles included here) |
||
double precision, | intent(in) | :: | x(npart_real) |
Array of coordinates |
||
double precision, | intent(in) | :: | y(npart_real) |
Array of coordinates |
||
double precision, | intent(in) | :: | z(npart_real) |
Array of coordinates |
||
double precision, | intent(out) | :: | pressure_id(npart) |
Array to store the pressure read from the \(\mathrm{ID}\) |
Reallocate the fields to be returned by perform_apm
FT 20.04.2022
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | npart_real |