mqc_json_output_types.f90 Source File

Unified JSON output data container Centralizes all data needed for JSON output from any calculation type


This file depends on

sourcefile~~mqc_json_output_types.f90~~EfferentGraph sourcefile~mqc_json_output_types.f90 mqc_json_output_types.f90 sourcefile~mqc_thermochemistry.f90 mqc_thermochemistry.f90 sourcefile~mqc_json_output_types.f90->sourcefile~mqc_thermochemistry.f90 sourcefile~mqc_elements.f90 mqc_elements.f90 sourcefile~mqc_thermochemistry.f90->sourcefile~mqc_elements.f90 sourcefile~mqc_physical_constants.f90 mqc_physical_constants.f90 sourcefile~mqc_thermochemistry.f90->sourcefile~mqc_physical_constants.f90

Files dependent on this one

sourcefile~~mqc_json_output_types.f90~~AfferentGraph sourcefile~mqc_json_output_types.f90 mqc_json_output_types.f90 sourcefile~mqc_driver.f90 mqc_driver.f90 sourcefile~mqc_driver.f90->sourcefile~mqc_json_output_types.f90 sourcefile~mqc_json_writer.f90 mqc_json_writer.f90 sourcefile~mqc_driver.f90->sourcefile~mqc_json_writer.f90 sourcefile~mqc_many_body_expansion.f90 mqc_many_body_expansion.f90 sourcefile~mqc_driver.f90->sourcefile~mqc_many_body_expansion.f90 sourcefile~mqc_mbe.f90 mqc_mbe.f90 sourcefile~mqc_driver.f90->sourcefile~mqc_mbe.f90 sourcefile~mqc_mbe_fragment_distribution_scheme.f90 mqc_mbe_fragment_distribution_scheme.F90 sourcefile~mqc_driver.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_gmbe_fragment_distribution_scheme.f90 mqc_gmbe_fragment_distribution_scheme.f90 sourcefile~mqc_gmbe_fragment_distribution_scheme.f90->sourcefile~mqc_json_output_types.f90 sourcefile~mqc_gmbe_fragment_distribution_scheme.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_json_writer.f90->sourcefile~mqc_json_output_types.f90 sourcefile~mqc_many_body_expansion.f90->sourcefile~mqc_json_output_types.f90 sourcefile~mqc_many_body_expansion.f90->sourcefile~mqc_gmbe_fragment_distribution_scheme.f90 sourcefile~mqc_many_body_expansion.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_mbe.f90->sourcefile~mqc_json_output_types.f90 sourcefile~mqc_mbe_fragment_distribution_scheme.f90->sourcefile~mqc_json_output_types.f90 sourcefile~mqc_mbe_fragment_distribution_scheme.f90->sourcefile~mqc_mbe.f90 sourcefile~mqc_mbe_fragment_distribution_scheme_hessian.f90 mqc_mbe_fragment_distribution_scheme_hessian.F90 sourcefile~mqc_mbe_fragment_distribution_scheme_hessian.f90->sourcefile~mqc_json_output_types.f90 sourcefile~mqc_mbe_fragment_distribution_scheme_hessian.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_mbe_mpi_fragment_distribution_scheme.f90 mqc_mbe_mpi_fragment_distribution_scheme.F90 sourcefile~mqc_mbe_mpi_fragment_distribution_scheme.f90->sourcefile~mqc_json_output_types.f90 sourcefile~mqc_mbe_mpi_fragment_distribution_scheme.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_serial_fragment_processor.f90 mqc_serial_fragment_processor.f90 sourcefile~mqc_serial_fragment_processor.f90->sourcefile~mqc_json_output_types.f90 sourcefile~mqc_serial_fragment_processor.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_unfragmented_workflow.f90 mqc_unfragmented_workflow.f90 sourcefile~mqc_unfragmented_workflow.f90->sourcefile~mqc_json_output_types.f90 sourcefile~mqc_unfragmented_workflow.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~main.f90 main.f90 sourcefile~main.f90->sourcefile~mqc_driver.f90 sourcefile~mqc_calculation_interface.f90 mqc_calculation_interface.f90 sourcefile~mqc_calculation_interface.f90->sourcefile~mqc_driver.f90

Source Code

!! Unified JSON output data container
!! Centralizes all data needed for JSON output from any calculation type
module mqc_json_output_types
   use pic_types, only: int64, dp
   use mqc_thermochemistry, only: thermochemistry_result_t
   implicit none
   private

   public :: json_output_data_t
   public :: OUTPUT_MODE_NONE, OUTPUT_MODE_UNFRAGMENTED, OUTPUT_MODE_MBE, OUTPUT_MODE_GMBE_PIE

   ! Output mode constants
   integer, parameter :: OUTPUT_MODE_NONE = 0
   integer, parameter :: OUTPUT_MODE_UNFRAGMENTED = 1
   integer, parameter :: OUTPUT_MODE_MBE = 2
   integer, parameter :: OUTPUT_MODE_GMBE_PIE = 3

   type :: json_output_data_t
      !! Unified container for all JSON output data
      !!
      !! This type consolidates all data needed to write JSON output for any
      !! calculation type (unfragmented, MBE, GMBE PIE). The output_mode field
      !! determines which format to use when writing JSON.

      integer :: output_mode = OUTPUT_MODE_NONE  !! OUTPUT_MODE_* constant

      !----- Common data -----
      real(dp) :: total_energy = 0.0_dp
      real(dp), allocatable :: gradient(:, :)     !! (3, natoms)
      real(dp), allocatable :: hessian(:, :)      !! (3*natoms, 3*natoms)
      real(dp), allocatable :: dipole(:)          !! (3)
      logical :: has_energy = .false.
      logical :: has_gradient = .false.
      logical :: has_hessian = .false.
      logical :: has_dipole = .false.

      !----- Vibrational data (optional) -----
      real(dp), allocatable :: frequencies(:)        !! cm^-1
      real(dp), allocatable :: reduced_masses(:)     !! amu
      real(dp), allocatable :: force_constants(:)    !! mdyne/Angstrom
      real(dp), allocatable :: ir_intensities(:)     !! km/mol
      type(thermochemistry_result_t) :: thermo
      logical :: has_vibrational = .false.
      logical :: has_ir_intensities = .false.

      !----- MBE-specific data (store ALL fragments for detailed output) -----
      integer, allocatable :: polymers(:, :)          !! Fragment composition (n_fragments, max_level)
      real(dp), allocatable :: fragment_energies(:)   !! Per-fragment total energies
      real(dp), allocatable :: delta_energies(:)      !! MBE delta corrections
      real(dp), allocatable :: sum_by_level(:)        !! Energy sum per level
      real(dp), allocatable :: fragment_distances(:)  !! Per-fragment min distances (Angstrom)
      integer(int64) :: fragment_count = 0
      integer :: max_level = 0

      !----- GMBE PIE-specific data -----
      integer, allocatable :: pie_atom_sets(:, :)     !! Unique atom sets (max_atoms, n_terms)
      integer, allocatable :: pie_coefficients(:)     !! PIE coefficients
      real(dp), allocatable :: pie_energies(:)        !! Per-term energies
      integer(int64) :: n_pie_terms = 0

   contains
      procedure :: destroy => json_output_data_destroy
      procedure :: reset => json_output_data_reset
   end type json_output_data_t

contains

   subroutine json_output_data_destroy(this)
      !! Clean up all allocated memory
      class(json_output_data_t), intent(inout) :: this

      ! Common data
      if (allocated(this%gradient)) deallocate (this%gradient)
      if (allocated(this%hessian)) deallocate (this%hessian)
      if (allocated(this%dipole)) deallocate (this%dipole)

      ! Vibrational data
      if (allocated(this%frequencies)) deallocate (this%frequencies)
      if (allocated(this%reduced_masses)) deallocate (this%reduced_masses)
      if (allocated(this%force_constants)) deallocate (this%force_constants)
      if (allocated(this%ir_intensities)) deallocate (this%ir_intensities)

      ! MBE data
      if (allocated(this%polymers)) deallocate (this%polymers)
      if (allocated(this%fragment_energies)) deallocate (this%fragment_energies)
      if (allocated(this%delta_energies)) deallocate (this%delta_energies)
      if (allocated(this%sum_by_level)) deallocate (this%sum_by_level)
      if (allocated(this%fragment_distances)) deallocate (this%fragment_distances)

      ! GMBE PIE data
      if (allocated(this%pie_atom_sets)) deallocate (this%pie_atom_sets)
      if (allocated(this%pie_coefficients)) deallocate (this%pie_coefficients)
      if (allocated(this%pie_energies)) deallocate (this%pie_energies)

      call this%reset()
   end subroutine json_output_data_destroy

   subroutine json_output_data_reset(this)
      !! Reset all flags and scalar values to defaults
      class(json_output_data_t), intent(inout) :: this

      this%output_mode = OUTPUT_MODE_NONE
      this%total_energy = 0.0_dp
      this%has_energy = .false.
      this%has_gradient = .false.
      this%has_hessian = .false.
      this%has_dipole = .false.
      this%has_vibrational = .false.
      this%has_ir_intensities = .false.
      this%fragment_count = 0
      this%max_level = 0
      this%n_pie_terms = 0
   end subroutine json_output_data_reset

end module mqc_json_output_types