Octopus
system_factory.F90
Go to the documentation of this file.
1!! Copyright (C) 2020, 2022 M. Oliveira
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
24 use debug_oct_m
25 use dftb_oct_m
28 use global_oct_m
29 use ions_oct_m
31 use matter_oct_m
36 use parser_oct_m
39 use system_oct_m
41 implicit none
42
43 private
44 public :: &
46
47 !# doc_start system_types
48 integer, parameter, public :: &
49 SYSTEM_ELECTRONIC = 1, & !< electronic system (electrons_oct_m::electrons_t)
50 system_maxwell = 2, &
53 system_dftbplus = 5, &
55 system_matter = 7, &
57 system_multisystem = 9, &
58 system_ions = 10
59 !# doc_end
60
67 contains
68 procedure :: create => system_factory_create
69 end type system_factory_t
70
71contains
72
73 ! ---------------------------------------------------------------------------------------
77 recursive function system_factory_create(this, namespace, type) result(system)
78 class(system_factory_t), intent(in) :: this
79 type(namespace_t), intent(in) :: namespace
80 integer, intent(in) :: type
81 class(system_t), pointer :: system
82
83 integer :: n_systems, is, ic, iother
84 type(block_t) :: blk
85 character(len=128), allocatable :: names(:)
86 integer, allocatable :: types(:)
87
88 push_sub(system_factory_create)
89
90 !%Variable Systems
91 !%Type block
92 !%Section System
93 !%Description
94 !% List of systems that will be treated in the calculation.
95 !% The first column should be a string containing the system name.
96 !% The second column should be the system type. See below for a list of
97 !% available system types.
98 !%Option electronic 1
99 !% An electronic system. (not fully implemented yet)
100 !%Option maxwell 2
101 !% A maxwell system.
102 !%Option classical_particle 3
103 !% A classical particle. Used for testing purposes only.
104 !%Option charged_particle 4
105 !% A charged classical particle.
106 !%Option dftbplus 5
107 !% A DFTB+ system
108 !%Option linear_medium 6
109 !% A linear medium for classical electrodynamics.
110 !%Option matter 7
111 !% A matter system containing electrons and classical ions.
112 !%Option dispersive_medium 8
113 !% (Experimental) A dispersive medium for classical electrodynamics.
114 !%Option multisystem 9
115 !% A system containing other systems.
116 !%Option ions 10
117 !% An ensemble of classical charged particles.
118 !%End
119 select case (type)
120 case (system_multisystem)
121
122 ! Parse the input file to get the list of subsystems
123 if (parse_block(namespace, 'Systems', blk) == 0) then
124
125 n_systems = parse_block_n(blk)
126 safe_allocate(names(1:n_systems))
127 safe_allocate(types(1:n_systems))
128
129 do is = 1, n_systems
130 ! Parse system name and type
131 call parse_block_string(blk, is - 1, 0, names(is))
132 if (len_trim(names(is)) == 0) then
133 call messages_input_error(namespace, 'Systems', 'All systems must have a name')
134 end if
136 if (index(trim(names(is)), parser_varname_excluded_characters(ic:ic)) /= 0) then
137 call messages_input_error(namespace, 'Systems', &
138 'Illegal character "' // parser_varname_excluded_characters(ic:ic) // '" in system name', row=is-1, column=0)
139 end if
140 end do
141 call parse_block_integer(blk, is - 1, 1, types(is))
142
143 ! Check that the system name is unique
144 do iother = 1, is-1
145 if (names(is) == names(iother)) then
146 call messages_input_error(namespace, 'Systems', 'Duplicated system in multi-system', &
147 row=is-1, column=0)
148 end if
149 end do
150
151 end do
152 call parse_block_end(blk)
153 else
154 call messages_input_error(namespace, 'Systems', 'Missing Systems block')
155 end if
156
157 system => multisystem_basic_t(namespace, names, types, this)
158
159 safe_deallocate_a(names)
160 safe_deallocate_a(types)
162 case (system_electronic)
163 system => electrons_t(namespace)
164 case (system_maxwell)
165 system => maxwell_t(namespace)
167 system => classical_particle_t(namespace)
169 system => charged_particle_t(namespace)
171 system => dftb_t(namespace)
173 system => linear_medium_t(namespace)
174 case (system_matter)
175 system => matter_t(namespace)
177 system => dispersive_medium_t(namespace)
178 call messages_experimental('dispersive_medium', namespace=namespace)
179 case (system_ions)
180 system => ions_t(namespace)
181 case default
182 call messages_input_error(namespace, 'Systems', 'Unknown system type.')
183 end select
184
185 pop_sub(system_factory_create)
186 end function system_factory_create
187
188end module system_factory_oct_m
189
190!! Local Variables:
191!! mode: f90
192!! coding: utf-8
193!! End:
This module defines a linear medium for use in classical electrodynamics calculations.
This module defines a container system for electrons and ions.
Definition: matter.F90:116
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:723
subroutine, public messages_experimental(name, namespace)
Definition: messages.F90:1097
This module implements the basic mulsisystem class, a container system for other systems.
character(len=27), parameter, public parser_varname_excluded_characters
The following characters should not be allowed in variable names.
Definition: parser.F90:154
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:618
This module defines the abstract class for the system factory.
integer, parameter, public system_matter
electrons including ions (matter_oct_m::matter_t)
integer, parameter, public system_ions
ensemble of charged classical particles (ions_oct_m::ions_t)
integer, parameter, public system_linear_medium
linear medium for Maxwell calculations (linear_medium_oct_m::linear_medium_t)
recursive class(system_t) function, pointer system_factory_create(this, namespace, type)
create a new system.
integer, parameter, public system_classical_particle
single classical particle (classical_particle_oct_m::classical_particle_t)
integer, parameter, public system_charged_particle
single charged classical particle (charged_particle_oct_m::charged_particle_t)
integer, parameter, public system_dispersive_medium
dispersive medium for classical electrodynamics (dispersive_medium_oct_m::dispersive_medium_t)
integer, parameter, public system_multisystem
container system. (multisystem_basic_oct_m::multisystem_basic_t)
integer, parameter, public system_dftbplus
tight binding system (dftb_oct_m::dftb_t)
integer, parameter, public system_maxwell
maxwell system, (maxwell_oct_m::maxwell_t)
This module implements the abstract system type.
Definition: system.F90:118
class for a charged classical particle
class for a neutral classical particle
class for a tight binding
Definition: dftb.F90:158
dispersive medium for classical electrodynamics calculations
Class describing the electron system.
Definition: electrons.F90:214
linear medium for classical electrodynamics
container class for for electrons and ions
Definition: matter.F90:136
Class describing Maxwell systems.
Definition: maxwell.F90:195
Container class for lists of system_oct_m::system_t.
factory for classes, derived from the abstract system_cot_m::system_t class