Octopus
modelmb_particles.F90
Go to the documentation of this file.
1!! Copyright (C) 2009 N. Helbig and M. Verstraete
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
25 use, intrinsic :: iso_fortran_env
26 use debug_oct_m
27 use global_oct_m
30 use parser_oct_m
32 use space_oct_m
33
34 implicit none
35
36 private
37
38 public :: &
44
49 private
50 integer, public :: ndim
52
53 integer, public :: ntype_of_particle
55 integer :: max_particles_per_type
56
57 integer, public :: nparticle = 0
58
59 integer :: ndensities_to_calculate
60
68 character(80), allocatable :: labels_particles(:)
69
70 integer, allocatable, public :: particletype(:)
71 integer, allocatable, public :: nparticles_per_type(:)
72 integer, allocatable, public :: particles_of_type(:,:)
73 integer, allocatable, public :: bosonfermion(:)
74
75 integer, allocatable :: exchange_symmetry(:,:,:)
76
77 real(real64), allocatable :: mass_particle(:)
78
79 real(real64), allocatable, public :: charge_particle(:)
80
88 character(80), allocatable :: labels_densities(:)
89
90 integer, allocatable :: particle_kept_densities(:)
91
92 contains
93 procedure :: copy_masses => modelmb_copy_masses
94 end type modelmb_particle_t
95
96contains
97
101 subroutine modelmb_particles_init(this, namespace, space)
102 type(modelmb_particle_t), intent(inout) :: this
103 type(namespace_t), intent(in) :: namespace
104 class(space_t), intent(in) :: space
105
106 integer :: ipart, ncols, nline, itmp, jtmp, ntype
107 type(block_t) :: blk
108
109 push_sub(modelmb_particles_init)
110
111 ! read in scalar dimensions
112
113 !%Variable NParticleModelmb
114 !%Type integer
115 !%Section States::ModelMB
116 !%Default 0
117 !%Description
118 !% Number of particles in modelmb space.
119 !% Full Ndim = <tt>NDimModelmb</tt>*<tt>NParticleModelmb</tt>
120 !%End
121 call parse_variable(namespace, 'NParticleModelmb', 0, this%nparticle)
122
123 if (this%nparticle == 0) then
125 return
126 end if
127
128 call messages_print_var_value("NParticleModelmb", this%nparticle, namespace=namespace)
129
130 !%Variable NDimModelmb
131 !%Type integer
132 !%Section States::ModelMB
133 !%Default 1
134 !%Description
135 !% Number of dimensions for modelmb space.
136 !% Full Ndim = <tt>NDimModelmb</tt>*<tt>NParticleModelmb</tt>
137 !%
138 !%End
139 call parse_variable(namespace, 'NDimModelmb', 1, this%ndim)
140 call messages_print_var_value("NDimModelmb", this%ndim, namespace=namespace)
142 !%Variable NTypeParticleModelmb
143 !%Type integer
144 !%Section States::ModelMB
145 !%Default 1
146 !%Description
147 !% Number of different types of particles in modelmb space.
148 !%End
149 call parse_variable(namespace, 'NTypeParticleModelmb', 1, this%ntype_of_particle)
150 call messages_print_var_value("NTypeParticleModelmb", this%ntype_of_particle, namespace=namespace)
151 if (this%ntype_of_particle > this%nparticle) then
152 write (message(1), '(2a,2I6)') ' Number of types of modelmb particles should be <= Number of modelmb particles ', &
153 this%ntype_of_particle, this%nparticle
154 call messages_fatal(1, namespace=namespace)
155 end if
156
157 if (this%ndim*this%nparticle /= space%dim) then
158 message(1) = ' Number of modelmb particles * dimension of modelmb space must be = Ndim'
159 call messages_fatal(1, namespace=namespace)
160 end if
162
163 ! allocate stuff
164 ntype = this%ntype_of_particle
165 safe_allocate(this%labels_particles(1:this%nparticle))
166 safe_allocate(this%particletype(1:this%nparticle))
167 safe_allocate(this%mass_particle(1:this%nparticle))
168 safe_allocate(this%charge_particle(1:this%nparticle))
169 safe_allocate(this%bosonfermion(1:this%nparticle))
170 safe_allocate(this%nparticles_per_type(1:ntype))
171 safe_allocate(this%particles_of_type(1:this%nparticle, 1:ntype))
173 ! default all particles are electrons
174 this%labels_particles = 'electron'
175 this%particletype = 1
176 this%mass_particle = m_one
177 this%charge_particle = m_one
178 this%bosonfermion = 1 ! set to fermion
179
180 !%Variable DescribeParticlesModelmb
181 !%Type block
182 !%Section States::ModelMB
183 !%Description
184 !% Characterization of different modelmb particles in space%dim dimensional space.
185 !%
186 !% <tt>%DescribeParticlesModelmb
187 !% <br>&nbsp;&nbsp; "proton" | 1 | 1800. | 1. | fermion
188 !% <br>&nbsp;&nbsp; "proton" | 1 | 1800. | 1. | fermion
189 !% <br>&nbsp;&nbsp; "electron" | 2 | 1. | 1. | fermion
190 !% <br>%</tt>
191 !%
192 !% would tell <tt>Octopus</tt> that there are presently 3 particles, called proton, proton,
193 !% and electron, with types 1, 1, and 2, and corresponding masses and charges.
194 !% All particles should be fermions, and this can be later enforced on the spatial
195 !% part of the wavefunctions.
196 !% The label and charge are presently only for informational purposes and
197 !% are not checked or used in <tt>Octopus</tt>. The interaction has to take the
198 !% actual charge into account.
199 !%
200 !%Option fermion 1
201 !% Particle is a fermion.
202 !%Option boson 2
203 !% Particle is a boson.
204 !%Option anyon 3
205 !% Particle is neither fermion nor boson.
206 !%End
207 if (parse_block(namespace, 'DescribeParticlesModelmb', blk) == 0) then
208
209 call messages_experimental("Model many-body", namespace=namespace)
210
211 ncols = parse_block_cols(blk, 0)
212 if (ncols /= 5) then
213 call messages_input_error(namespace, "DescribeParticlesModelmb")
214 end if
215 nline = parse_block_n(blk)
216 if (nline /= this%nparticle) then
217 call messages_input_error(namespace, "DescribeParticlesModelmb")
218 end if
219
220 do ipart = 1, this%nparticle
221 call parse_block_string(blk, ipart - 1, 0, this%labels_particles(ipart))
222 call parse_block_integer(blk, ipart - 1, 1, this%particletype(ipart))
223 call parse_block_float(blk, ipart - 1, 2, this%mass_particle(ipart))
224 call parse_block_float(blk, ipart - 1, 3, this%charge_particle(ipart))
225 call parse_block_integer(blk, ipart - 1, 4, this%bosonfermion(ipart))
226
227 write (message(1),'(a,a)') 'labels_particles = ', this%labels_particles(ipart)
228 write (message(2),'(a,i6)') 'particletype = ', this%particletype(ipart)
229 write (message(3),'(a,E20.10)') 'mass_particle = ', this%mass_particle(ipart)
230 write (message(4),'(a,E20.10)') 'charge_particle = ', this%charge_particle(ipart)
231 write (message(5),'(a,i6)') 'bosonfermion = ', this%bosonfermion(ipart)
232 call messages_info(5, namespace=namespace)
233 end do
234 call parse_block_end(blk)
235
236 end if
237
238 this%nparticles_per_type = 0
239 this%particles_of_type = 0
240 do ipart = 1, this%nparticle
241 this%nparticles_per_type(this%particletype(ipart)) = &
242 this%nparticles_per_type(this%particletype(ipart)) + 1
243 this%particles_of_type(this%nparticles_per_type(this%particletype(ipart)), &
244 this%particletype(ipart)) = ipart
245 end do
246
247 this%max_particles_per_type = maxval(this%nparticles_per_type)
248 itmp = this%max_particles_per_type
249 jtmp = this%ntype_of_particle
250 safe_allocate(this%exchange_symmetry(1:itmp, 1:itmp, 1:jtmp))
251 this%exchange_symmetry = 0
252
254
255 end subroutine modelmb_particles_init
256
257
258 subroutine modelmb_particles_end (this)
259 type(modelmb_particle_t),intent(inout) :: this
260
261 push_sub(modelmb_particles_end)
262
263 safe_deallocate_a(this%labels_particles)
264 safe_deallocate_a(this%particletype)
265 safe_deallocate_a(this%mass_particle)
266 safe_deallocate_a(this%charge_particle)
267 safe_deallocate_a(this%nparticles_per_type)
268 safe_deallocate_a(this%particles_of_type)
269 safe_deallocate_a(this%exchange_symmetry)
270 safe_deallocate_a(this%bosonfermion)
271
272 safe_deallocate_a(this%labels_densities)
273 safe_deallocate_a(this%particle_kept_densities)
274
275 pop_sub(modelmb_particles_end)
276 end subroutine modelmb_particles_end
277
278 subroutine modelmb_particles_copy(modelmb_out, modelmb_in)
279 type(modelmb_particle_t), intent(in) :: modelmb_in
280 type(modelmb_particle_t), intent(inout) :: modelmb_out
281
282 push_sub(modelmb_particles_copy)
283
284 call modelmb_particles_end(modelmb_out)
285
286 modelmb_out%ndim = modelmb_in%ndim
287 modelmb_out%ntype_of_particle = modelmb_in%ntype_of_particle
288 modelmb_out%max_particles_per_type = modelmb_in%max_particles_per_type
289 modelmb_out%nparticle = modelmb_in%nparticle
290 modelmb_out%ndensities_to_calculate = modelmb_in%ndensities_to_calculate
291
292 safe_allocate_source_a(modelmb_out%labels_particles,modelmb_in%labels_particles)
293 safe_allocate_source_a(modelmb_out%particletype,modelmb_in%particletype)
294 safe_allocate_source_a(modelmb_out%mass_particle,modelmb_in%mass_particle)
295 safe_allocate_source_a(modelmb_out%charge_particle,modelmb_in%charge_particle)
296 safe_allocate_source_a(modelmb_out%nparticles_per_type,modelmb_in%nparticles_per_type)
297 safe_allocate_source_a(modelmb_out%particles_of_type,modelmb_in%particles_of_type)
298 safe_allocate_source_a(modelmb_out%exchange_symmetry,modelmb_in%exchange_symmetry)
299 safe_allocate_source_a(modelmb_out%bosonfermion,modelmb_in%bosonfermion)
300
301 safe_allocate_source_a(modelmb_out%labels_densities,modelmb_in%labels_densities)
302 safe_allocate_source_a(modelmb_out%particle_kept_densities,modelmb_in%particle_kept_densities)
303
305 end subroutine modelmb_particles_copy
306
308 subroutine modelmb_copy_masses(this, masses)
309 class(modelmb_particle_t), intent(in) :: this
310 real(real64), intent(inout) :: masses(:)
311
312 real(real64), parameter :: tol_mass = 1.e-10_real64
313 integer :: dimcounter,ipart
314
315 push_sub(modelmb_copy_masses)
316
317 ! copy masses to gr%der%masses
318 dimcounter = 0
319 do ipart = 1,this%nparticle
320 if (abs(this%mass_particle(ipart)-1.0_real64) > tol_mass) then
321 masses(dimcounter+1:dimcounter+this%ndim) = this%mass_particle(ipart)
322 end if
323 dimcounter = dimcounter+this%ndim
324 end do
325
326 pop_sub(modelmb_copy_masses)
327 end subroutine modelmb_copy_masses
328
330
331!! Local Variables:
332!! mode: f90
333!! coding: utf-8
334!! End:
Prints out to iunit a message in the form: ["InputVariable" = value] where "InputVariable" is given b...
Definition: messages.F90:180
real(real64), parameter, public m_one
Definition: global.F90:188
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:160
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:420
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:723
subroutine, public messages_experimental(name, namespace)
Definition: messages.F90:1097
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:624
general module for modelmb particles
subroutine, public modelmb_copy_masses(this, masses)
Copy masses for particles. To be used for the derivative object.
subroutine, public modelmb_particles_end(this)
subroutine, public modelmb_particles_init(this, namespace, space)
==============================================================
subroutine, public modelmb_particles_copy(modelmb_out, modelmb_in)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:618
==============================================================