mqc_mbe Module

Implements hierarchical many-body expansion for fragment-based quantum chemistry calculations with MPI parallelization and energy/gradient computation. MBE energy with optional gradient and hessian GMBE energy with optional gradient and hessian


Uses

  • module~~mqc_mbe~~UsesGraph module~mqc_mbe mqc_mbe module~mqc_frag_utils mqc_frag_utils module~mqc_mbe->module~mqc_frag_utils module~mqc_gmbe_utils mqc_gmbe_utils module~mqc_mbe->module~mqc_gmbe_utils module~mqc_json_output_types mqc_json_output_types module~mqc_mbe->module~mqc_json_output_types module~mqc_mbe_io mqc_mbe_io module~mqc_mbe->module~mqc_mbe_io module~mqc_mpi_tags mqc_mpi_tags module~mqc_mbe->module~mqc_mpi_tags module~mqc_physical_fragment mqc_physical_fragment module~mqc_mbe->module~mqc_physical_fragment module~mqc_program_limits mqc_program_limits module~mqc_mbe->module~mqc_program_limits module~mqc_thermochemistry mqc_thermochemistry module~mqc_mbe->module~mqc_thermochemistry module~mqc_vibrational_analysis mqc_vibrational_analysis module~mqc_mbe->module~mqc_vibrational_analysis pic_io pic_io module~mqc_mbe->pic_io pic_logger pic_logger module~mqc_mbe->pic_logger pic_mpi_lib pic_mpi_lib module~mqc_mbe->pic_mpi_lib pic_timer pic_timer module~mqc_mbe->pic_timer pic_types pic_types module~mqc_mbe->pic_types module~mqc_frag_utils->module~mqc_gmbe_utils module~mqc_frag_utils->module~mqc_physical_fragment module~mqc_frag_utils->pic_io module~mqc_frag_utils->pic_logger module~mqc_frag_utils->pic_types module~mqc_combinatorics mqc_combinatorics module~mqc_frag_utils->module~mqc_combinatorics module~mqc_fragment_lookup mqc_fragment_lookup module~mqc_frag_utils->module~mqc_fragment_lookup module~mqc_gmbe_utils->module~mqc_physical_fragment module~mqc_gmbe_utils->pic_io module~mqc_gmbe_utils->pic_logger module~mqc_gmbe_utils->pic_types module~mqc_gmbe_utils->module~mqc_combinatorics module~mqc_error mqc_error module~mqc_gmbe_utils->module~mqc_error module~mqc_result_types mqc_result_types module~mqc_gmbe_utils->module~mqc_result_types module~mqc_json_output_types->module~mqc_thermochemistry module~mqc_json_output_types->pic_types module~mqc_mbe_io->module~mqc_physical_fragment module~mqc_mbe_io->pic_io module~mqc_mbe_io->pic_logger module~mqc_mbe_io->pic_types module~mqc_elements mqc_elements module~mqc_mbe_io->module~mqc_elements module~mqc_mpi_tags->pic_types module~mqc_physical_fragment->pic_types module~mqc_cgto mqc_cgto module~mqc_physical_fragment->module~mqc_cgto module~mqc_physical_fragment->module~mqc_elements module~mqc_physical_fragment->module~mqc_error module~mqc_geometry mqc_geometry module~mqc_physical_fragment->module~mqc_geometry module~mqc_physical_constants mqc_physical_constants module~mqc_physical_fragment->module~mqc_physical_constants module~mqc_xyz_reader mqc_xyz_reader module~mqc_physical_fragment->module~mqc_xyz_reader module~mqc_program_limits->pic_types module~mqc_thermochemistry->pic_io module~mqc_thermochemistry->pic_logger module~mqc_thermochemistry->pic_types module~mqc_thermochemistry->module~mqc_elements module~mqc_thermochemistry->module~mqc_physical_constants pic_lapack_interfaces pic_lapack_interfaces module~mqc_thermochemistry->pic_lapack_interfaces module~mqc_vibrational_analysis->module~mqc_thermochemistry module~mqc_vibrational_analysis->pic_logger module~mqc_vibrational_analysis->pic_types module~mqc_vibrational_analysis->module~mqc_elements module~mqc_vibrational_analysis->module~mqc_physical_constants module~mqc_vibrational_analysis->pic_lapack_interfaces module~mqc_cgto->pic_types module~mqc_combinatorics->pic_types module~mqc_elements->pic_types pic_ascii pic_ascii module~mqc_elements->pic_ascii module~mqc_fragment_lookup->pic_types module~mqc_fragment_lookup->module~mqc_error pic_hash_32bit pic_hash_32bit module~mqc_fragment_lookup->pic_hash_32bit pic_sorting pic_sorting module~mqc_fragment_lookup->pic_sorting module~mqc_geometry->pic_types module~mqc_physical_constants->pic_types module~mqc_result_types->pic_mpi_lib module~mqc_result_types->pic_types module~mqc_result_types->module~mqc_error module~mqc_xyz_reader->pic_types module~mqc_xyz_reader->module~mqc_error module~mqc_xyz_reader->module~mqc_geometry

Used by

  • module~~mqc_mbe~~UsedByGraph module~mqc_mbe mqc_mbe module~mqc_driver mqc_driver module~mqc_driver->module~mqc_mbe module~mqc_mbe_fragment_distribution_scheme mqc_mbe_fragment_distribution_scheme module~mqc_driver->module~mqc_mbe_fragment_distribution_scheme module~mqc_mbe_fragment_distribution_scheme->module~mqc_mbe module~mpi_fragment_work_smod mpi_fragment_work_smod module~mpi_fragment_work_smod->module~mqc_mbe_fragment_distribution_scheme module~mqc_gmbe_fragment_distribution_scheme mqc_gmbe_fragment_distribution_scheme module~mqc_gmbe_fragment_distribution_scheme->module~mqc_mbe_fragment_distribution_scheme module~mqc_hessian_distribution_scheme mqc_hessian_distribution_scheme module~mqc_hessian_distribution_scheme->module~mqc_mbe_fragment_distribution_scheme module~mqc_serial_fragment_processor mqc_serial_fragment_processor module~mqc_serial_fragment_processor->module~mqc_mbe_fragment_distribution_scheme module~mqc_unfragmented_workflow mqc_unfragmented_workflow module~mqc_unfragmented_workflow->module~mqc_mbe_fragment_distribution_scheme proc~compute_energy_and_forces compute_energy_and_forces proc~compute_energy_and_forces->module~mqc_driver proc~gmbe_run_distributed gmbe_context_t%gmbe_run_distributed proc~gmbe_run_distributed->module~mqc_mbe_fragment_distribution_scheme proc~gmbe_run_distributed->module~mqc_gmbe_fragment_distribution_scheme proc~mbe_run_distributed mbe_context_t%mbe_run_distributed proc~mbe_run_distributed->module~mqc_mbe_fragment_distribution_scheme proc~mbe_run_serial mbe_context_t%mbe_run_serial proc~mbe_run_serial->module~mqc_mbe_fragment_distribution_scheme program~main main program~main->module~mqc_driver proc~gmbe_run_serial gmbe_context_t%gmbe_run_serial proc~gmbe_run_serial->module~mqc_gmbe_fragment_distribution_scheme

Functions

private function compute_mbe_delta(fragment_idx, fragment, lookup, energies, delta_energies, n, world_comm) result(delta_E)

Bottom-up computation of n-body correction (non-recursive, uses pre-computed subset deltas) deltaE(i1,i2,…,in) = E(i1,i2,…,in) - sum of all subset deltaE values All subsets must have been computed already (guaranteed by processing fragments in order)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: fragment_idx

Index of this fragment (already known)

integer, intent(in) :: fragment(:)
type(fragment_lookup_t), intent(in) :: lookup

Pre-built hash table for lookups

real(kind=dp), intent(in) :: energies(:)

Pre-computed delta values

real(kind=dp), intent(in) :: delta_energies(:)

Pre-computed delta values

integer, intent(in) :: n
type(comm_t), intent(in), optional :: world_comm

MPI communicator for abort

Return Value real(kind=dp)


Subroutines

public subroutine compute_gmbe(monomers, n_monomers, monomer_results, n_intersections, intersection_results, intersection_sets, intersection_levels, total_energy, sys_geom, total_gradient, total_hessian, bonds, world_comm)

Compute generalized many-body expansion (GMBE) energy with optional gradient and/or hessian

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: monomers(:)
integer, intent(in) :: n_monomers
type(calculation_result_t), intent(in) :: monomer_results(:)
integer, intent(in) :: n_intersections
type(calculation_result_t), intent(in), optional :: intersection_results(:)
integer, intent(in), optional :: intersection_sets(:,:)
integer, intent(in), optional :: intersection_levels(:)
real(kind=dp), intent(out) :: total_energy
type(system_geometry_t), intent(in), optional :: sys_geom
real(kind=dp), intent(out), optional :: total_gradient(:,:)
real(kind=dp), intent(out), optional :: total_hessian(:,:)
type(bond_t), intent(in), optional :: bonds(:)
type(comm_t), intent(in), optional :: world_comm

public subroutine compute_mbe(polymers, fragment_count, max_level, results, mbe_result, sys_geom, world_comm, json_data)

Compute many-body expansion (MBE) energy with optional gradient, hessian, and dipole

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: polymers(:,:)
integer(kind=int64), intent(in) :: fragment_count
integer, intent(in) :: max_level
type(calculation_result_t), intent(in) :: results(:)
type(mbe_result_t), intent(inout) :: mbe_result

Pre-allocated by caller

type(system_geometry_t), intent(in), optional :: sys_geom

Required for gradient/hessian

type(comm_t), intent(in), optional :: world_comm

MPI communicator for abort

type(json_output_data_t), intent(out), optional :: json_data

JSON output data

private subroutine build_mbe_lookup_table(polymers, fragment_count, max_level, lookup, error)

Build hash table for fast fragment lookups

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: polymers(:,:)
integer(kind=int64), intent(in) :: fragment_count
integer, intent(in) :: max_level
type(fragment_lookup_t), intent(inout) :: lookup
type(error_t), intent(out), optional :: error

private subroutine compute_mbe_dipole(fragment_idx, fragment, lookup, results, delta_dipoles, n, world_comm)

Bottom-up computation of n-body dipole correction Exactly mirrors the energy MBE logic: deltaDipole = Dipole - sum(all subset deltaDipoles) Dipoles are additive vectors in the system frame, no coordinate mapping needed

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: fragment_idx
integer, intent(in) :: fragment(:)
type(fragment_lookup_t), intent(in) :: lookup
type(calculation_result_t), intent(in) :: results(:)
real(kind=dp), intent(inout) :: delta_dipoles(:,:)

(3, fragment_count)

integer, intent(in) :: n
type(comm_t), intent(in), optional :: world_comm

MPI communicator for abort

private subroutine compute_mbe_dipole_derivatives(fragment_idx, fragment, lookup, results, delta_dipole_derivs, n, sys_geom)

Bottom-up computation of n-body dipole derivative correction Mirrors MBE Hessian logic but for dipole derivatives Bond connectivity is accessed via sys_geom%bonds

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: fragment_idx
integer, intent(in) :: fragment(:)
type(fragment_lookup_t), intent(in) :: lookup
type(calculation_result_t), intent(in) :: results(:)
real(kind=dp), intent(inout) :: delta_dipole_derivs(:,:,:)

(3, 3*total_atoms, fragment_count)

integer, intent(in) :: n
type(system_geometry_t), intent(in) :: sys_geom

private subroutine compute_mbe_gradient(fragment_idx, fragment, lookup, results, delta_gradients, n, sys_geom, world_comm)

Bottom-up computation of n-body gradient correction Exactly mirrors the energy MBE logic: deltaG = G - sum(all subset deltaGs) All gradients are in system coordinates, so subtraction is simple Bond connectivity is accessed via sys_geom%bonds

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: fragment_idx
integer, intent(in) :: fragment(:)
type(fragment_lookup_t), intent(in) :: lookup
type(calculation_result_t), intent(in) :: results(:)
real(kind=dp), intent(inout) :: delta_gradients(:,:,:)

(3, total_atoms, fragment_count)

integer, intent(in) :: n
type(system_geometry_t), intent(in) :: sys_geom
type(comm_t), intent(in), optional :: world_comm

MPI communicator for abort

private subroutine compute_mbe_hessian(fragment_idx, fragment, lookup, results, delta_hessians, n, sys_geom)

Bottom-up computation of n-body Hessian correction Mirrors MBE gradient logic but for second derivatives Bond connectivity is accessed via sys_geom%bonds

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: fragment_idx
integer, intent(in) :: fragment(:)
type(fragment_lookup_t), intent(in) :: lookup
type(calculation_result_t), intent(in) :: results(:)
real(kind=dp), intent(inout) :: delta_hessians(:,:,:)

(3total_atoms, 3total_atoms, fragment_count)

integer, intent(in) :: n
type(system_geometry_t), intent(in) :: sys_geom

private subroutine get_monomer_atom_list(sys_geom, monomer_idx, atom_list, n_atoms)

Build 0-indexed atom list for a monomer, handling fixed or variable-sized fragments.

Arguments

Type IntentOptional Attributes Name
type(system_geometry_t), intent(in) :: sys_geom
integer, intent(in) :: monomer_idx
integer, intent(out), allocatable :: atom_list(:)
integer, intent(out) :: n_atoms

private subroutine map_fragment_to_system_dipole_derivatives(frag_dipole_derivs, monomers, sys_geom, sys_dipole_derivs)

Map fragment dipole derivatives to system coordinates with hydrogen cap redistribution

Read more…

Arguments

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

(3, 3*natoms_frag)

integer, intent(in) :: monomers(:)
type(system_geometry_t), intent(in) :: sys_geom
real(kind=dp), intent(inout) :: sys_dipole_derivs(:,:)

(3, 3*total_atoms)

private subroutine map_fragment_to_system_gradient(frag_grad, monomers, sys_geom, sys_grad, world_comm)

Map fragment gradient to system gradient coordinates with hydrogen cap redistribution

Read more…

Arguments

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

(3, natoms_frag)

integer, intent(in) :: monomers(:)

Monomer indices in fragment

type(system_geometry_t), intent(in) :: sys_geom
real(kind=dp), intent(inout) :: sys_grad(:,:)

(3, total_atoms)

type(comm_t), intent(in), optional :: world_comm

MPI communicator for abort

private subroutine map_fragment_to_system_hessian(frag_hess, monomers, sys_geom, sys_hess)

Map fragment Hessian to system Hessian coordinates with hydrogen cap redistribution Bond connectivity is accessed via sys_geom%bonds

Arguments

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

(3natoms_frag, 3natoms_frag)

integer, intent(in) :: monomers(:)
type(system_geometry_t), intent(in) :: sys_geom
real(kind=dp), intent(inout) :: sys_hess(:,:)

(3total_atoms, 3total_atoms)

private subroutine print_mbe_energy_breakdown(sum_by_level, max_level, total_energy)

Print MBE energy breakdown to logger

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: sum_by_level(:)
integer, intent(in) :: max_level
real(kind=dp), intent(in) :: total_energy

private subroutine print_mbe_gradient_info(total_gradient, sys_geom, current_log_level)

Print MBE gradient information

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: total_gradient(:,:)
type(system_geometry_t), intent(in) :: sys_geom
integer, intent(in) :: current_log_level

private subroutine process_intersection_derivatives(inter_idx, k, sign_factor, intersection_results, intersection_sets, sys_geom, total_gradient, total_hessian, bonds, compute_grad, compute_hess, hess_dim, world_comm)

Process derivatives for a single intersection fragment

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: inter_idx
integer, intent(in) :: k
real(kind=dp), intent(in) :: sign_factor
type(calculation_result_t), intent(in) :: intersection_results(:)
integer, intent(in) :: intersection_sets(:,:)
type(system_geometry_t), intent(in) :: sys_geom
real(kind=dp), intent(inout) :: total_gradient(:,:)
real(kind=dp), intent(inout), optional :: total_hessian(:,:)
type(bond_t), intent(in), optional :: bonds(:)
logical, intent(in) :: compute_grad
logical, intent(in) :: compute_hess
integer, intent(in) :: hess_dim
type(comm_t), intent(in), optional :: world_comm