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 end type modelmb_particle_t
93
94contains
95
99 subroutine modelmb_particles_init(this, namespace, space)
100 type(modelmb_particle_t), intent(inout) :: this
101 type(namespace_t), intent(in) :: namespace
102 class(space_t), intent(in) :: space
103
104 integer :: ipart, ncols, nline, itmp, jtmp, npar, ntype
105 type(block_t) :: blk
106
107 push_sub(modelmb_particles_init)
108
109 ! read in scalar dimensions
110
111 !%Variable NParticleModelmb
112 !%Type integer
113 !%Section States::ModelMB
114 !%Default 0
115 !%Description
116 !% Number of particles in modelmb space.
117 !% Full Ndim = <tt>NDimModelmb</tt>*<tt>NParticleModelmb</tt>
118 !%End
119 call parse_variable(namespace, 'NParticleModelmb', 0, this%nparticle)
120
121 if (this%nparticle == 0) then
123 return
124 end if
125
126 call messages_print_var_value("NParticleModelmb", this%nparticle, namespace=namespace)
127
128 !%Variable NDimModelmb
129 !%Type integer
130 !%Section States::ModelMB
131 !%Default 1
132 !%Description
133 !% Number of dimensions for modelmb space.
134 !% Full Ndim = <tt>NDimModelmb</tt>*<tt>NParticleModelmb</tt>
135 !%
136 !%End
137 call parse_variable(namespace, 'NDimModelmb', 1, this%ndim)
138 call messages_print_var_value("NDimModelmb", this%ndim, namespace=namespace)
139
140 !%Variable NTypeParticleModelmb
141 !%Type integer
142 !%Section States::ModelMB
143 !%Default 1
144 !%Description
145 !% Number of different types of particles in modelmb space.
146 !%End
147 call parse_variable(namespace, 'NTypeParticleModelmb', 1, this%ntype_of_particle)
148 call messages_print_var_value("NTypeParticleModelmb", this%ntype_of_particle, namespace=namespace)
149 if (this%ntype_of_particle > this%nparticle) then
150 write (message(1), '(2a,2I6)') ' Number of types of modelmb particles should be <= Number of modelmb particles ', &
151 this%ntype_of_particle, this%nparticle
152 call messages_fatal(1, namespace=namespace)
153 end if
154
155 if (this%ndim*this%nparticle /= space%dim) then
156 message(1) = ' Number of modelmb particles * dimension of modelmb space must be = Ndim'
157 call messages_fatal(1, namespace=namespace)
158 end if
159
160 ! read in blocks
162 !%Variable DescribeParticlesModelmb
163 !%Type block
164 !%Section States::ModelMB
165 !%Description
166 !% Characterization of different modelmb particles in space%dim dimensional space.
167 !%
168 !% <tt>%DescribeParticlesModelmb
169 !% <br>&nbsp;&nbsp; "proton" | 1 | 1800. | 1. | fermion
170 !% <br>&nbsp;&nbsp; "proton" | 1 | 1800. | 1. | fermion
171 !% <br>&nbsp;&nbsp; "electron" | 2 | 1. | 1. | fermion
172 !% <br>%</tt>
173 !%
174 !% would tell <tt>Octopus</tt> that there are presently 3 particles, called proton, proton,
175 !% and electron, with types 1, 1, and 2, and corresponding masses and charges.
176 !% All particles should be fermions, and this can be later enforced on the spatial
177 !% part of the wavefunctions.
178 !% The label and charge are presently only for informational purposes and
179 !% are not checked or used in <tt>Octopus</tt>. The interaction has to take the
180 !% actual charge into account.
181 !%
182 !%Option fermion 1
183 !% Particle is a fermion.
184 !%Option boson 2
185 !% Particle is a boson.
186 !%Option anyon 3
187 !% Particle is neither fermion nor boson.
188 !%End
189
190 ! allocate stuff
191 npar = this%nparticle
192 ntype = this%ntype_of_particle
193 safe_allocate(this%labels_particles(1:npar))
194 safe_allocate(this%particletype(1:npar))
195 safe_allocate(this%mass_particle(1:npar))
196 safe_allocate(this%charge_particle(1:npar))
197 safe_allocate(this%bosonfermion(1:npar))
198 safe_allocate(this%nparticles_per_type(1:ntype))
199 safe_allocate(this%particles_of_type(1:npar, 1:ntype))
200
201 ! default all particles are electrons
202 this%labels_particles = 'electron'
203 this%particletype = 1
204 this%mass_particle = m_one
205 this%charge_particle = m_one
206 this%bosonfermion = 1 ! set to fermion
207
208
209 if (parse_block(namespace, 'DescribeParticlesModelmb', blk) == 0) then
210
211 call messages_experimental("Model many-body", namespace=namespace)
212
213 ncols = parse_block_cols(blk, 0)
214 if (ncols /= 5) then
215 call messages_input_error(namespace, "DescribeParticlesModelmb")
216 end if
217 nline = parse_block_n(blk)
218 if (nline /= this%nparticle) then
219 call messages_input_error(namespace, "DescribeParticlesModelmb")
220 end if
221
222 do ipart = 1, this%nparticle
223 call parse_block_string(blk, ipart - 1, 0, this%labels_particles(ipart))
224 call parse_block_integer(blk, ipart - 1, 1, this%particletype(ipart))
225 call parse_block_float(blk, ipart - 1, 2, this%mass_particle(ipart))
226 call parse_block_float(blk, ipart - 1, 3, this%charge_particle(ipart))
227 call parse_block_integer(blk, ipart - 1, 4, this%bosonfermion(ipart))
228
229 write (message(1),'(a,a)') 'labels_particles = ', this%labels_particles(ipart)
230 write (message(2),'(a,i6)') 'particletype = ', this%particletype(ipart)
231 write (message(3),'(a,E20.10)') 'mass_particle = ', this%mass_particle(ipart)
232 write (message(4),'(a,E20.10)') 'charge_particle = ', this%charge_particle(ipart)
233 write (message(5),'(a,i6)') 'bosonfermion = ', this%bosonfermion(ipart)
234 call messages_info(5, namespace=namespace)
235 end do
236 call parse_block_end(blk)
237
238 end if
239
240 this%nparticles_per_type = 0
241 this%particles_of_type = 0
242 do ipart = 1, this%nparticle
243 this%nparticles_per_type(this%particletype(ipart)) = &
244 this%nparticles_per_type(this%particletype(ipart)) + 1
245 this%particles_of_type(this%nparticles_per_type(this%particletype(ipart)), &
246 this%particletype(ipart)) = ipart
247 end do
248
249 this%max_particles_per_type = maxval(this%nparticles_per_type)
250 itmp = this%max_particles_per_type
251 jtmp = this%ntype_of_particle
252 safe_allocate(this%exchange_symmetry(1:itmp, 1:itmp, 1:jtmp))
253 this%exchange_symmetry = 0
254
256
257 end subroutine modelmb_particles_init
258
259
260 subroutine modelmb_particles_end (this)
261 type(modelmb_particle_t),intent(inout) :: this
262
263 push_sub(modelmb_particles_end)
264
265 safe_deallocate_a(this%labels_particles)
266 safe_deallocate_a(this%particletype)
267 safe_deallocate_a(this%mass_particle)
268 safe_deallocate_a(this%charge_particle)
269 safe_deallocate_a(this%nparticles_per_type)
270 safe_deallocate_a(this%particles_of_type)
271 safe_deallocate_a(this%exchange_symmetry)
272 safe_deallocate_a(this%bosonfermion)
273
274 safe_deallocate_a(this%labels_densities)
275 safe_deallocate_a(this%particle_kept_densities)
276
277 pop_sub(modelmb_particles_end)
278 end subroutine modelmb_particles_end
279
280 subroutine modelmb_particles_copy(modelmb_out, modelmb_in)
281 type(modelmb_particle_t), intent(in) :: modelmb_in
282 type(modelmb_particle_t), intent(inout) :: modelmb_out
283
284 push_sub(modelmb_particles_copy)
285
286 call modelmb_particles_end(modelmb_out)
287
288 modelmb_out%ndim = modelmb_in%ndim
289 modelmb_out%ntype_of_particle = modelmb_in%ntype_of_particle
290 modelmb_out%max_particles_per_type = modelmb_in%max_particles_per_type
291 modelmb_out%nparticle = modelmb_in%nparticle
292 modelmb_out%ndensities_to_calculate = modelmb_in%ndensities_to_calculate
293
294 safe_allocate_source_a(modelmb_out%labels_particles,modelmb_in%labels_particles)
295 safe_allocate_source_a(modelmb_out%particletype,modelmb_in%particletype)
296 safe_allocate_source_a(modelmb_out%mass_particle,modelmb_in%mass_particle)
297 safe_allocate_source_a(modelmb_out%charge_particle,modelmb_in%charge_particle)
298 safe_allocate_source_a(modelmb_out%nparticles_per_type,modelmb_in%nparticles_per_type)
299 safe_allocate_source_a(modelmb_out%particles_of_type,modelmb_in%particles_of_type)
300 safe_allocate_source_a(modelmb_out%exchange_symmetry,modelmb_in%exchange_symmetry)
301 safe_allocate_source_a(modelmb_out%bosonfermion,modelmb_in%bosonfermion)
302
303 safe_allocate_source_a(modelmb_out%labels_densities,modelmb_in%labels_densities)
304 safe_allocate_source_a(modelmb_out%particle_kept_densities,modelmb_in%particle_kept_densities)
305
307 end subroutine modelmb_particles_copy
308
312 subroutine modelmb_copy_masses(this, masses)
313 type(modelmb_particle_t), intent(in) :: this
314 real(real64), intent(inout) :: masses(:)
315
316 integer :: dimcounter,ipart
317
318 push_sub(modelmb_copy_masses)
319
320 ! copy masses to gr%der%masses
321 dimcounter = 0
322 do ipart = 1,this%nparticle
323 if (abs(this%mass_particle(ipart)-1.0_real64) > 1.e-10_real64) then
324 masses(dimcounter+1:dimcounter+this%ndim) = this%mass_particle(ipart)
325 end if
326 dimcounter = dimcounter+this%ndim
327 end do
328
329 pop_sub(modelmb_copy_masses)
330 end subroutine modelmb_copy_masses
331
333
334!! Local Variables:
335!! mode: f90
336!! coding: utf-8
337!! 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
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
Definition: messages.F90:624
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
general module for modelmb particles
subroutine, public modelmb_copy_masses(this, masses)
==============================================================
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
==============================================================