Octopus
wigner_distribution.F90
Go to the documentation of this file.
1!! Copyright (C) 2024 M. Lueders
2!!
3!! This Source Code Form is subject to the terms of the Mozilla Public
4!! License, v. 2.0. If a copy of the MPL was not distributed with this
5!! file, You can obtain one at https://mozilla.org/MPL/2.0/.
6!!
7#include "global.h"
8
10
11 use, intrinsic :: iso_fortran_env
12 use debug_oct_m
14 use global_oct_m
17
18 private
19 public :: &
21
22
23 integer, parameter, public :: &
24 WIGNER_Q = 1, &
25 wigner_p = 2
26
30
31 private
32
33 integer :: num_modes
34 real(real64), allocatable :: random_numbers(:, :)
35
36 contains
37
38 procedure :: init => wigner_distribution_init
39 procedure :: end => wigner_distribution_end
40 procedure :: get => wigner_distribution_get
41
43
44contains
45
50 !
51 subroutine wigner_distribution_init(this, num_modes, seed)
52 class(wigner_distribution_t), intent(inout) :: this
53 integer, intent(in) :: num_modes
54 integer(int64), intent(in) :: seed
55
56 integer(int64) :: local_seed
57
59
60 assert(seed /= 0)
61
62 this%num_modes = num_modes
63 local_seed = seed
64
65 safe_allocate(this%random_numbers(1:num_modes, 1:2))
66 this%random_numbers = normal_distribution_get_random(local_seed, this%num_modes)
67
69 end subroutine wigner_distribution_init
70
72 subroutine wigner_distribution_end(this)
73 class(wigner_distribution_t), intent(inout) :: this
74
76 safe_deallocate_a(this%random_numbers)
78 end subroutine wigner_distribution_end
79
86 !
87 function wigner_distribution_get(this, sigma, mu, set) result(values)
88 class(wigner_distribution_t), intent(inout) :: this
89 real(real64), intent(in) :: sigma(1:this%num_modes)
90 real(real64), intent(in) :: mu(1:this%num_modes)
91 integer, intent(in) :: set
92
93 real(real64) :: values(1:this%num_modes)
94
96
97 assert(set==wigner_q .or. set==wigner_p)
98 values = sigma*this%random_numbers(:,set) + mu
99
101 end function wigner_distribution_get
102
103
This module provides a random number generator for a normalized gaussian distribution.
real(real64) function, dimension(1:n, 1:2), public normal_distribution_get_random(seed, n)
This function implements the Box Mueller algorithm to produce n pairs of normal distributed random nu...
integer, parameter, public wigner_p
real(real64) function, dimension(1:this%num_modes) wigner_distribution_get(this, sigma, mu, set)
Get random numbers with given standard deviation and mean per mode.
subroutine wigner_distribution_init(this, num_modes, seed)
Initialize the Wigner distribution.
subroutine wigner_distribution_end(this)
Deallocate internal memory.
Class describing a Wigner distribution for sampling initial conditions in multi-trajectory Ehrenfest ...