Octopus
dipole.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
8#include "global.h"
9
14!
15module dipole_oct_m
16 use debug_oct_m
17 use global_oct_m
18 use ions_oct_m
19 use mesh_oct_m
22 use space_oct_m
24 implicit none
25
26 private
27 public :: &
29
30 type :: dipole_t
31 private
32
33 integer :: dim
34 logical :: periodic
35 real(real64), allocatable :: dipole(:)
36
37 contains
38 procedure :: init => dipole_init
39 procedure :: calculate => dipole_calculate
40 procedure :: get => dipole_get
41 procedure :: end => dipole_end
42 end type dipole_t
43
44contains
45
49 subroutine dipole_init(this, space)
50 class(dipole_t), intent(out) :: this
51 class(space_t), intent(in) :: space
52
53 this%periodic = space%is_periodic()
54 this%dim = space%dim
55
56 safe_allocate(this%dipole(1:this%dim))
57 this%dipole = m_zero
58
59 end subroutine dipole_init
60
62 subroutine dipole_end(this)
63 class(dipole_t), intent(inout) :: this
64
65 safe_deallocate_a(this%dipole)
66
67 end subroutine dipole_end
68
71 subroutine dipole_calculate(this, gr, ions, st)
72 class(dipole_t), intent(inout) :: this
73 class(mesh_t), intent(in) :: gr
74 type(ions_t), intent(in) :: ions
75 type(states_elec_t), intent(in) :: st
76
77 push_sub(dipole_calculate)
78
79 this%dipole = - ions%dipole() - st%dipole(gr)
80
81 pop_sub(dipole_calculate)
82 end subroutine dipole_calculate
83
85 function dipole_get(this) result(dipole)
86 class(dipole_t), intent(in) :: this
87 real(real64) :: dipole(1:this%dim)
88
89 push_sub(dipole_get)
90 assert(.not. this%periodic) ! remove this assertion once properly implemented
91 dipole = this%dipole
92
93 pop_sub(dipole_get)
94 end function
95
96end module dipole_oct_m
This modules implements the dipole moment of the matter system.
Definition: dipole.F90:108
subroutine dipole_init(this, space)
initialize the dipole moment
Definition: dipole.F90:143
real(real64) function, dimension(1:this%dim) dipole_get(this)
accedd the dipole moment
Definition: dipole.F90:179
subroutine dipole_calculate(this, gr, ions, st)
Calculate the dipole moment from the ions and the electronic states.
Definition: dipole.F90:165
subroutine dipole_end(this)
finalizer: release memory
Definition: dipole.F90:156
real(real64), parameter, public m_zero
Definition: global.F90:187
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:118