Octopus
dftb.F90
Go to the documentation of this file.
1!! Copyright (C) 2020 F. Bonafé, H. Appel
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
21module dftb_oct_m
23 use debug_oct_m
24#ifdef HAVE_DFTBPLUS
25 use dftbplus
26#endif
27 use global_oct_m
31 use io_oct_m
33 use ions_oct_m
34 use, intrinsic :: iso_fortran_env
35 use lasers_oct_m
37 use mpi_oct_m
40 use parser_oct_m
46 use system_oct_m
48 use unit_oct_m
51
52 implicit none
53
54 private
55 public :: &
56 dftb_t, &
58
59 integer, parameter :: &
60 OUTPUT_COORDINATES = 1, &
62
65 type, extends(system_t) :: dftb_t
66 integer :: n_atom
67 real(real64), allocatable :: coords(:,:), gradients(:,:)
68 real(real64), allocatable :: acc(:,:)
69 real(real64), allocatable :: tot_force(:,:)
70 real(real64), allocatable :: vel(:,:)
71 real(real64), allocatable :: prev_tot_force(:,:)
72 integer, allocatable :: species(:)
73 integer :: dynamics
74 real(real64), allocatable :: mass(:)
75 real(real64), allocatable :: atom_charges(:,:)
76 character(len=LABEL_LEN), allocatable :: labels(:)
77 real(real64), allocatable :: prev_acc(:,:,:)
78 real(real64) :: scc_tolerance
79 class(ions_t), pointer :: ions => null()
80 type(c_ptr) :: output_handle(2)
81 type(ion_dynamics_t) :: ions_dyn
82 class(lasers_t), pointer :: lasers => null()
83 logical :: laser_field
84 real(real64) :: field(3)
85 real(real64) :: energy
86#ifdef HAVE_DFTBPLUS
87 type(TDftbPlus) :: dftbp
88#endif
89 contains
90 procedure :: init_interaction => dftb_init_interaction
91 procedure :: initial_conditions => dftb_initial_conditions
92 procedure :: do_algorithmic_operation => dftb_do_algorithmic_operation
93 procedure :: output_start => dftb_output_start
94 procedure :: output_write => dftb_output_write
95 procedure :: output_finish => dftb_output_finish
96 procedure :: is_tolerance_reached => dftb_is_tolerance_reached
97 procedure :: copy_quantities_to_interaction => dftb_copy_quantities_to_interaction
98 procedure :: init_interaction_as_partner => dftb_init_interaction_as_partner
99 procedure :: update_interactions_start => dftb_update_interactions_start
100 procedure :: restart_write_data => dftb_restart_write_data
101 procedure :: restart_read_data => dftb_restart_read_data
102 procedure :: update_kinetic_energy => dftb_update_kinetic_energy
103 final :: dftb_finalize
104 end type dftb_t
105
106 interface dftb_t
107 procedure dftb_constructor
108 end interface dftb_t
109
111 integer, parameter :: &
112 EHRENFEST = 1, &
113 bo = 2
115contains
116
117 ! ---------------------------------------------------------
122 function dftb_constructor(namespace) result(sys)
123 class(dftb_t), pointer :: sys
124 type(namespace_t), intent(in) :: namespace
125
126 push_sub(dftb_constructor)
127
128 allocate(sys)
129
130 call dftb_init(sys, namespace)
131
132 pop_sub(dftb_constructor)
133 end function dftb_constructor
134
135 ! ---------------------------------------------------------
140 ! ---------------------------------------------------------
141 subroutine dftb_init(this, namespace)
142 class(dftb_t), target, intent(inout) :: this
143 type(namespace_t), intent(in) :: namespace
144
145 integer :: ii, jj, ispec
146 character(len=MAX_PATH_LEN) :: slako_dir
147 character(len=1), allocatable :: max_ang_mom(:)
148 character(len=LABEL_LEN) :: this_max_ang_mom, this_label
149 integer :: n_maxang_block
150 type(block_t) :: blk
151 real(real64) :: initial_temp
153#ifdef HAVE_DFTBPLUS
154 type(tdftbplusinput) :: input
155 type(fnode), pointer :: proot, pgeo, pham, pdftb, pmaxang, pslakos, ptype2files, panalysis
156 type(fnode), pointer :: pparseropts
157 type(fnode), pointer :: pelecdyn, pperturb, plaser
158#endif
160 push_sub(dftb_init)
162 this%namespace = namespace
164 ! Currently this system does not support any interaction
165 allocate(this%supported_interactions(0))
166 allocate(this%supported_interactions_as_partner(0))
168 call messages_print_with_emphasis(msg="DFTB+ System", namespace=namespace)
170 this%ions => ions_t(namespace)
171 this%n_atom = this%ions%natoms
172 safe_allocate(this%coords(1:3, 1:this%n_atom))
173 safe_allocate(this%acc(1:3, 1:this%n_atom))
174 safe_allocate(this%vel(1:3, 1:this%n_atom))
175 safe_allocate(this%tot_force(1:3, 1:this%n_atom))
176 safe_allocate(this%prev_tot_force(1:3, 1:this%n_atom))
177 safe_allocate(this%gradients(1:3, 1:this%n_atom))
178 safe_allocate(this%species(1:this%n_atom))
179 safe_allocate(this%mass(1:this%n_atom))
180 safe_allocate(this%atom_charges(1:this%n_atom, 1))
181 safe_allocate(this%labels(1:this%ions%nspecies))
182 safe_allocate(max_ang_mom(1:this%ions%nspecies))
184 ispec = 1
185 this%species(1) = 1
186 this%labels(1) = trim(this%ions%atom(1)%label)
188 this%coords = this%ions%pos
189 ! mass is read from the default pseudopotential files
190 this%mass = this%ions%mass
191 do ii = 1, this%n_atom
192 if ((ii > 1) .and. .not. (any(this%labels(1:ispec) == this%ions%atom(ii)%label))) then
193 ispec = ispec + 1
194 this%labels(ispec) = trim(this%ions%atom(ii)%label)
195 end if
196 do jj = 1, ispec
197 if (trim(this%ions%atom(ii)%label) == trim(this%labels(jj))) then
198 this%species(ii) = jj
199 end if
200 end do
201 end do
202 this%vel = m_zero
203 this%tot_force = m_zero
205 !%Variable MaxAngularMomentum
206 !%Type block
207 !%Section DFTBPlusInterface
208 !%Description
209 !% Specifies the highest angular momentum for each atom type. All orbitals up
210 !% to that angular momentum will be included in the calculation.
211 !% Possible values for the angular momenta are s, p, d, f.
212 !% These are examples:
213 !%
214 !% <tt>%MaxAngularMomentum
215 !% <br>&nbsp;&nbsp;'O' | 'p'
216 !% <br>&nbsp;&nbsp;'H' | 's'
217 !% <br>%</tt>
218 !%End
219 n_maxang_block = 0
220 if (parse_block(namespace, 'MaxAngularMomentum', blk) == 0) then
221 n_maxang_block = parse_block_n(blk)
222 if (n_maxang_block /= this%ions%nspecies) then
223 call messages_input_error(namespace, "MaxAngularMomentum", "Wrong number of species.")
224 end if
225
226 do ii = 1, n_maxang_block
227 call parse_block_string(blk, ii-1, 0, this_label)
228 call parse_block_string(blk, ii-1, 1, this_max_ang_mom)
229 if (any(["s","p","d","f"] == trim(this_max_ang_mom))) then
230 call messages_input_error(namespace, "MaxAngularMomentum", "Wrong maximum angular momentum for element"//trim(this_label))
231 end if
232 do jj = 1, this%ions%nspecies
233 if (trim(adjustl(this_label)) == trim(adjustl(this%labels(jj)))) then
234 max_ang_mom(jj) = trim(adjustl(this_max_ang_mom))
235 end if
236 end do
237 end do
238 end if
239 call parse_block_end(blk)
240
241 !%Variable SlakoDir
242 !%Type string
243 !%Default "./"
244 !%Section Execution::IO
245 !%Description
246 !% Folder containing the Slako files
247 !%End
248 call parse_variable(namespace, 'SlakoDir', './', slako_dir)
249
250
251 ! Dynamics variables
252
253 call ion_dynamics_init(this%ions_dyn, namespace, this%ions)
254
255 call parse_variable(namespace, 'TDDynamics', bo, this%dynamics)
256 call messages_print_var_option('TDDynamics', this%dynamics, namespace=namespace)
257 if (this%dynamics == bo) then
258 call ion_dynamics_unfreeze(this%ions_dyn)
259 end if
260
261 !%Variable InitialIonicTemperature
262 !%Type float
263 !%Default 0.0
264 !%Section DFTBPlusInterface
265 !%Description
266 !% If this variable is present, the ions will have initial velocities
267 !% velocities to the atoms following a Boltzmann distribution with
268 !% this temperature (in Kelvin). Used only if <tt>TDDynamics = Ehrenfest</tt>
269 !% and <tt>MoveIons = yes</tt>.
270 !%End
271 call parse_variable(namespace, 'InitialIonicTemperature', m_zero, initial_temp, unit = unit_kelvin)
272
273 this%lasers => lasers_t(namespace)
274 call lasers_parse_external_fields(this%lasers)
275 if (this%lasers%no_lasers > 0) then
276 this%laser_field = .true.
277 else
278 this%laser_field = .false.
279 end if
280
281#ifdef HAVE_DFTBPLUS
282 call tdftbplus_init(this%dftbp)
283
284 call this%dftbp%getEmptyInput(input)
285 call input%getRootNode(proot)
286 call setchild(proot, "Geometry", pgeo)
287 call setchildvalue(pgeo, "Periodic", .false.)
288 call setchildvalue(pgeo, "TypeNames", this%labels(1:this%ions%nspecies))
289 call setchildvalue(pgeo, "TypesAndCoordinates", reshape(this%species, [1, size(this%species)]), this%coords)
290 call setchild(proot, "Hamiltonian", pham)
291 call setchild(pham, "Dftb", pdftb)
292 call setchildvalue(pdftb, "Scc", .true.)
293
294 !%Variable SccTolerance
295 !%Type float
296 !%Section DFTBPlusInterface
297 !%Description
298 !% Self-consistent-charges convergence tolerance. Once this
299 !% tolerance has been achieved the SCC cycle will stop.
300 !%End
301 call parse_variable(namespace, 'SccTolerance', 1e-9_real64, this%scc_tolerance)
302 call messages_print_var_value('SccTolerance', this%scc_tolerance, namespace=namespace)
303 call setchildvalue(pdftb, "SccTolerance", this%scc_tolerance)
304
305 ! sub-block inside hamiltonian for the maximum angular momenta
306 call setchild(pdftb, "MaxAngularMomentum", pmaxang)
307 ! explicitly set the maximum angular momenta for the species
308 do ii = 1, this%ions%nspecies
309 call setchildvalue(pmaxang, this%labels(ii), max_ang_mom(ii))
310 end do
311
312 ! get the SK data
313 ! You should provide the skfiles as found in the external/slakos/origin/mio-1-1/ folder. These can
314 ! be downloaded with the utils/get_opt_externals script
315 call setchild(pdftb, "SlaterKosterFiles", pslakos)
316 call setchild(pslakos, "Type2FileNames", ptype2files)
317 call setchildvalue(ptype2files, "Prefix", slako_dir)
318 call setchildvalue(ptype2files, "Separator", "-")
319 call setchildvalue(ptype2files, "Suffix", ".skf")
320
321 ! set up analysis options
322 call setchild(proot, "Analysis", panalysis)
323 call setchildvalue(panalysis, "CalculateForces", .true.)
324
325 call setchild(proot, "ParserOptions", pparseropts)
326 call setchildvalue(pparseropts, "ParserVersion", 5)
327
328 if (this%dynamics == ehrenfest) then
329 call setchild(proot, "ElectronDynamics", pelecdyn)
330 call setchildvalue(pelecdyn, "IonDynamics", ion_dynamics_ions_move(this%ions_dyn))
331 if (ion_dynamics_ions_move(this%ions_dyn)) then
332 call setchildvalue(pelecdyn, "InitialTemperature", initial_temp)
333 end if
334
335 ! initialize with wrong arguments for the moment, will be overriden later
336 call setchildvalue(pelecdyn, "Steps", 1)
337 call setchildvalue(pelecdyn, "TimeStep", m_one)
338 call setchild(pelecdyn, "Perturbation", pperturb)
339 if (this%laser_field) then
340 call setchild(pperturb, "Laser", plaser)
341 call setchildvalue(plaser, "PolarizationDirection", [ m_one , m_zero , m_zero ])
342 call setchildvalue(plaser, "LaserEnergy", m_one)
343 call setchildvalue(pelecdyn, "FieldStrength", m_one)
344 else
345 call setchild(pperturb, "None", plaser)
346 end if
347 end if
348
349 message(1) = 'Input tree in HSD format:'
350 call messages_info(1, namespace=namespace)
351 call dumphsd(input%hsdTree, stdout)
352
353 ! initialise the DFTB+ calculator
354 call this%dftbp%setupCalculator(input)
355 call this%dftbp%setGeometry(this%coords)
356#endif
357
358 pop_sub(dftb_init)
359 end subroutine dftb_init
360
361 ! ---------------------------------------------------------
362 subroutine dftb_init_interaction(this, interaction)
363 class(dftb_t), target, intent(inout) :: this
364 class(interaction_t), intent(inout) :: interaction
365
366 push_sub(dftb_init_interaction)
367
368 select type (interaction)
369 class default
370 message(1) = "Trying to initialize an unsupported interaction by DFTB+."
371 call messages_fatal(1, namespace=this%namespace)
372 end select
373
374 pop_sub(dftb_init_interaction)
375 end subroutine dftb_init_interaction
376
377 ! ---------------------------------------------------------
378 subroutine dftb_initial_conditions(this)
379 class(dftb_t), intent(inout) :: this
380
382
383#ifdef HAVE_DFTBPLUS
384 select type (algo => this%algo)
385 class is (propagator_t)
386 select case (this%dynamics)
387 case (bo)
388 call this%dftbp%getGradients(this%gradients)
389 this%tot_force = -this%gradients
390 case (ehrenfest)
391 call this%dftbp%getEnergy(this%energy)
392 call this%dftbp%initializeTimeProp(algo%dt, this%laser_field, .false.)
393 end select
394 end select
395#endif
396
398 end subroutine dftb_initial_conditions
399
400 ! ---------------------------------------------------------
401 logical function dftb_do_algorithmic_operation(this, operation, updated_quantities) result(done)
402 class(dftb_t), intent(inout) :: this
403 class(algorithmic_operation_t), intent(in) :: operation
404 integer, allocatable, intent(out) :: updated_quantities(:)
405
406 integer :: ii, jj, il
407 type(tdf_t) :: ff, phi
408 complex(real64) :: amp, pol(3)
409 real(real64) :: time, omega
410
412 call profiling_in(trim(this%namespace%get())//":"//trim(operation%id))
413
414 select type (algo => this%algo)
415 class is (propagator_t)
416
417 done = .true.
418 select case (this%dynamics)
419 case (bo)
420 ! Born-Oppenheimer dynamics
421 select case (operation%id)
423 ! Do nothing
424
425 case (verlet_start)
426 safe_allocate(this%prev_acc(1:3, 1:this%n_atom, 1))
427 do jj = 1, this%n_atom
428 this%acc(1:3, jj) = this%tot_force(1:3, jj) / this%mass(jj)
429 end do
430
431 case (verlet_finish)
432 safe_deallocate_a(this%prev_acc)
433
434 case (verlet_update_pos)
435 do jj = 1, this%n_atom
436 this%coords(1:3, jj) = this%coords(1:3, jj) + algo%dt * this%vel(1:3, jj) &
437 + m_half * algo%dt**2 * this%acc(1:3, jj)
438 end do
439 updated_quantities = [position]
440
441 case (verlet_compute_acc)
442 do ii = size(this%prev_acc, dim=3) - 1, 1, -1
443 this%prev_acc(1:3, 1:this%n_atom, ii + 1) = this%prev_acc(1:3, 1:this%n_atom, ii)
444 end do
445 this%prev_acc(1:3, 1:this%n_atom, 1) = this%acc(1:3, 1:this%n_atom)
446#ifdef HAVE_DFTBPLUS
447 call this%dftbp%setGeometry(this%coords)
448 call this%dftbp%getGradients(this%gradients)
449 this%tot_force = -this%gradients
450#endif
451 do jj = 1, this%n_atom
452 this%acc(1:3, jj) = this%tot_force(1:3, jj) / this%mass(jj)
453 end do
454
456 this%vel(1:3, 1:this%n_atom) = this%vel(1:3, 1:this%n_atom) &
457 + m_half * algo%dt * (this%prev_acc(1:3, 1:this%n_atom, 1) + &
458 this%acc(1:3, 1:this%n_atom))
459 updated_quantities = [velocity]
460
461 case default
462 done = .false.
463 end select
464
465 case (ehrenfest)
466 ! Ehrenfest dynamics
467 select case (operation%id)
469 ! Do nothing
470 case (verlet_start)
471 !Do nothing
472 case (verlet_finish)
473 !Do nothing
474 case (verlet_update_pos)
475 this%field = m_zero
476 time = this%iteration%value()
477 do il = 1, this%lasers%no_lasers
478 ! get properties of laser
479 call laser_get_f(this%lasers%lasers(il), ff)
480 call laser_get_phi(this%lasers%lasers(il), phi)
481 omega = laser_carrier_frequency(this%lasers%lasers(il))
482 pol = laser_polarization(this%lasers%lasers(il))
483 ! calculate electric field from laser
484 amp = tdf(ff, time) * exp(m_zi * (omega*time + tdf(phi, time)))
485 this%field(1:3) = this%field(1:3) + real(amp*pol(1:3), real64)
486 end do
487#ifdef HAVE_DFTBPLUS
488 call this%dftbp%setTdElectricField(this%field)
489 call this%dftbp%doOneTdStep(this%iteration%counter(), atomnetcharges=this%atom_charges, coord=this%coords,&
490 force=this%tot_force, energy=this%energy)
491#endif
492 case (verlet_compute_acc)
493 !Do nothing
495 !Do nothing
496 case default
497 done = .false.
498 end select
499
500 end select
501
502 end select
503
504 call profiling_out(trim(this%namespace%get())//":"//trim(operation%id))
507
508 ! ---------------------------------------------------------
509 logical function dftb_is_tolerance_reached(this, tol) result(converged)
510 class(dftb_t), intent(in) :: this
511 real(real64), intent(in) :: tol
512
514
515 ! this routine is never called at present, no reason to be here
516 assert(.false.)
517 converged = .false.
518
520 end function dftb_is_tolerance_reached
521
522 ! ---------------------------------------------------------
523 subroutine dftb_output_start(this)
524 class(dftb_t), intent(inout) :: this
525
526 push_sub(dftb_output_start)
527
528 select type (algo => this%algo)
529 class is (propagator_t)
530 ! Create output handle
531 call io_mkdir('td.general', this%namespace)
532 if (mpi_grp_is_root(mpi_world)) then
533 call write_iter_init(this%output_handle(output_coordinates), 0, algo%dt, &
534 trim(io_workpath("td.general/coordinates", this%namespace)))
535 call write_iter_init(this%output_handle(output_forces), 0, algo%dt, &
536 trim(io_workpath("td.general/forces", this%namespace)))
537 end if
538
539 ! Output info for first iteration
540 call this%output_write()
541 end select
542
543 pop_sub(dftb_output_start)
544 end subroutine dftb_output_start
545
546 ! ---------------------------------------------------------
547 subroutine dftb_output_finish(this)
548 class(dftb_t), intent(inout) :: this
549
550 push_sub(dftb_output_finish)
551
552 select type (algo => this%algo)
553 class is (propagator_t)
554 if (mpi_grp_is_root(mpi_world)) then
555 call write_iter_end(this%output_handle(output_coordinates))
556 call write_iter_end(this%output_handle(output_forces))
557 end if
558 end select
559
560 pop_sub(dftb_output_finish)
561 end subroutine dftb_output_finish
562
563 ! ---------------------------------------------------------
564 subroutine dftb_output_write(this)
565 class(dftb_t), intent(inout) :: this
566
567 integer :: idir, iat, iout
568 character(len=50) :: aux
569 character(1) :: out_label(2)
570 real(real64) :: tmp(3)
571
572 if (.not. mpi_grp_is_root(mpi_world)) return ! only first node outputs
573
574 push_sub(dftb_output_write)
575 call profiling_in(trim(this%namespace%get())//":"//"OUTPUT_WRITE")
576
577 select type (algo => this%algo)
578 class is (propagator_t)
579 out_label(1) = "x"
580 out_label(2) = "f"
581
582 if (this%iteration%counter() == 0) then
583 ! header
584 do iout = 1, 2
585 call write_iter_clear(this%output_handle(iout))
586 call write_iter_string(this%output_handle(iout),'#####################################################################')
587 call write_iter_nl(this%output_handle(iout))
588 call write_iter_string(this%output_handle(iout),'# HEADER')
589 call write_iter_nl(this%output_handle(iout))
590
591 ! first line: column names
592 call write_iter_header_start(this%output_handle(iout))
593
594 do iat = 1, this%n_atom
595 do idir = 1, 3
596 write(aux, '(a1,a1,i3,a1,i3,a1)') out_label(iout),'(', iat, ',', idir, ')'
597 call write_iter_header(this%output_handle(iout), aux)
598 end do
599 end do
600 call write_iter_nl(this%output_handle(iout))
601
602 ! second line: units
603 call write_iter_string(this%output_handle(iout), '#[Iter n.]')
604 call write_iter_header(this%output_handle(iout), '[' // trim(units_abbrev(units_out%time)) // ']')
605 end do
606
607 do iat = 1, this%n_atom
608 do idir = 1, 3
609 call write_iter_header(this%output_handle(output_coordinates), '[' // trim(units_abbrev(units_out%length)) // ']')
610 call write_iter_header(this%output_handle(output_forces), '[' // trim(units_abbrev(units_out%force)) // ']')
611 end do
612 end do
613
614 do iout = 1, 2
615 call write_iter_nl(this%output_handle(iout))
616 call write_iter_string(this%output_handle(iout),'#######################################################################')
617 call write_iter_nl(this%output_handle(iout))
618 end do
619 end if
620
621 call write_iter_start(this%output_handle(output_coordinates))
622 call write_iter_start(this%output_handle(output_forces))
623
624 do iat = 1, this%n_atom
625 ! Position
626 tmp(1:3) = units_from_atomic(units_out%length, this%coords(1:3, iat))
627 call write_iter_double(this%output_handle(output_coordinates), tmp, 3)
628 ! Force
629 tmp(1:3) = units_from_atomic(units_out%force, this%tot_force(1:3, iat))
630 call write_iter_double(this%output_handle(output_forces), tmp, 3)
631 end do
632
633 call write_iter_nl(this%output_handle(output_coordinates))
634 call write_iter_nl(this%output_handle(output_forces))
635
636 end select
637
638 call profiling_out(trim(this%namespace%get())//":"//"OUTPUT_WRITE")
639 pop_sub(dftb_output_write)
640 end subroutine dftb_output_write
641
642 ! ---------------------------------------------------------
643 subroutine dftb_init_interaction_as_partner(partner, interaction)
644 class(dftb_t), intent(in) :: partner
645 class(interaction_surrogate_t), intent(inout) :: interaction
646
648
649 select type (interaction)
650 class default
651 message(1) = "Unsupported interaction."
652 call messages_fatal(1, namespace=partner%namespace)
653 end select
654
658 ! ---------------------------------------------------------
659 subroutine dftb_copy_quantities_to_interaction(partner, interaction)
660 class(dftb_t), intent(inout) :: partner
661 class(interaction_surrogate_t), intent(inout) :: interaction
662
664
665 select type (interaction)
666 class default
667 message(1) = "Unsupported interaction."
668 call messages_fatal(1, namespace=partner%namespace)
669 end select
670
673
674 ! ---------------------------------------------------------
675 subroutine dftb_update_interactions_start(this)
676 class(dftb_t), intent(inout) :: this
677
679
680 ! Store previous force, as it is used as SCF criterium
681 this%prev_tot_force(1:3, 1:this%n_atom) = this%tot_force(1:3, 1:this%n_atom)
682
684 end subroutine dftb_update_interactions_start
685
686 ! ---------------------------------------------------------
687 subroutine dftb_update_kinetic_energy(this)
688 class(dftb_t), intent(inout) :: this
689
691
692 this%kinetic_energy = m_zero
693
695 end subroutine dftb_update_kinetic_energy
696
697 ! ---------------------------------------------------------
698 subroutine dftb_restart_write_data(this)
699 class(dftb_t), intent(inout) :: this
700
702
703 message(1) = "DFTB system "//trim(this%namespace%get())//" cannot write restart data."
704 call messages_warning(1, namespace=this%namespace)
705
707 end subroutine dftb_restart_write_data
708
709 ! ---------------------------------------------------------
710 ! this function returns true if restart data could be read
711 logical function dftb_restart_read_data(this)
712 class(dftb_t), intent(inout) :: this
713
714 push_sub(dftb_restart_read_data)
715
716 ! restarting not yet supported
717 dftb_restart_read_data = .false.
718
720 end function dftb_restart_read_data
721
722 ! ---------------------------------------------------------
723 subroutine dftb_finalize(this)
724 type(dftb_t), intent(inout) :: this
725
726 push_sub(dftb_finalize)
727
728 safe_deallocate_a(this%coords)
729 safe_deallocate_a(this%acc)
730 safe_deallocate_a(this%vel)
731 safe_deallocate_a(this%tot_force)
732 safe_deallocate_a(this%prev_tot_force)
733 safe_deallocate_a(this%gradients)
734 safe_deallocate_a(this%species)
735 safe_deallocate_a(this%mass)
736 call ion_dynamics_end(this%ions_dyn)
737
738 deallocate(this%ions)
739
740 ! No call to safe_deallocate macro here, as it gives an ICE with gfortran
741 if (associated(this%lasers)) then
742 deallocate(this%lasers)
743 end if
744
745#ifdef HAVE_DFTBPLUS
746 call tdftbplus_destruct(this%dftbp)
747#endif
748
749 call system_end(this)
750
751 pop_sub(dftb_finalize)
752 end subroutine dftb_finalize
753
754end module dftb_oct_m
755
756!! Local Variables:
757!! mode: f90
758!! coding: utf-8
759!! End:
Prints out to iunit a message in the form: ["InputVariable" = value] where "InputVariable" is given b...
Definition: messages.F90:180
Writes to the corresponding file and adds one to the iteration. Must be called after write_iter_init(...
Definition: write_iter.F90:167
double exp(double __x) __attribute__((__nothrow__
This module implements the basic elements defining algorithms.
Definition: algorithm.F90:141
subroutine dftb_output_write(this)
Definition: dftb.F90:658
subroutine dftb_update_interactions_start(this)
Definition: dftb.F90:769
subroutine dftb_init_interaction_as_partner(partner, interaction)
Definition: dftb.F90:737
subroutine dftb_output_finish(this)
Definition: dftb.F90:641
subroutine dftb_restart_write_data(this)
Definition: dftb.F90:792
subroutine dftb_init_interaction(this, interaction)
Definition: dftb.F90:456
logical function dftb_restart_read_data(this)
Definition: dftb.F90:805
logical function dftb_do_algorithmic_operation(this, operation, updated_quantities)
Definition: dftb.F90:495
class(dftb_t) function, pointer dftb_constructor(namespace)
The factory routine (or constructor) allocates a pointer of the corresponding type and then calls the...
Definition: dftb.F90:216
subroutine, public dftb_init(this, namespace)
The init routine is a module level procedure This has the advantage that different classes can have d...
Definition: dftb.F90:235
subroutine dftb_update_kinetic_energy(this)
Definition: dftb.F90:781
integer, parameter output_forces
Definition: dftb.F90:152
subroutine dftb_finalize(this)
Definition: dftb.F90:817
subroutine dftb_initial_conditions(this)
Definition: dftb.F90:472
logical function dftb_is_tolerance_reached(this, tol)
Definition: dftb.F90:603
subroutine dftb_output_start(this)
Definition: dftb.F90:617
integer, parameter bo
Definition: dftb.F90:204
subroutine dftb_copy_quantities_to_interaction(partner, interaction)
Definition: dftb.F90:753
real(real64), parameter, public m_zero
Definition: global.F90:187
complex(real64), parameter, public m_zi
Definition: global.F90:201
real(real64), parameter, public m_half
Definition: global.F90:193
real(real64), parameter, public m_one
Definition: global.F90:188
This module defines the abstract interaction_t class, and some auxiliary classes for interactions.
Definition: io.F90:114
character(len=max_path_len) function, public io_workpath(path, namespace)
Definition: io.F90:313
subroutine, public io_mkdir(fname, namespace, parents)
Definition: io.F90:354
logical pure function, public ion_dynamics_ions_move(this)
subroutine, public ion_dynamics_unfreeze(this)
Unfreezes the ionic movement.
subroutine, public ion_dynamics_init(this, namespace, ions)
subroutine, public ion_dynamics_end(this)
complex(real64) function, dimension(3), public laser_polarization(laser)
Definition: lasers.F90:722
subroutine, public lasers_parse_external_fields(this)
Definition: lasers.F90:243
subroutine, public laser_get_f(laser, ff)
Definition: lasers.F90:763
real(real64) function, public laser_carrier_frequency(laser)
Definition: lasers.F90:619
subroutine, public laser_get_phi(laser, phi)
Definition: lasers.F90:791
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
Definition: messages.F90:930
character(len=512), private msg
Definition: messages.F90:165
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:543
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
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
Definition: mpi.F90:430
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:266
This module implements the multisystem debug functionality.
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:618
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
Definition: profiling.F90:623
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
Definition: profiling.F90:552
This module implements the basic propagator framework.
Definition: propagator.F90:117
character(len=algo_label_len), parameter, public store_current_status
Definition: propagator.F90:167
character(len=30), parameter, public verlet_start
character(len=30), parameter, public verlet_compute_acc
character(len=30), parameter, public verlet_update_pos
character(len=30), parameter, public verlet_finish
character(len=30), parameter, public verlet_compute_vel
This module defines the quantity_t class and the IDs for quantities, which can be exposed by a system...
Definition: quantity.F90:137
integer, parameter, public velocity
Definition: quantity.F90:146
integer, parameter, public position
Definition: quantity.F90:146
This module implements the abstract system type.
Definition: system.F90:118
subroutine, public system_end(this)
Definition: system.F90:1116
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Definition: unit.F90:132
character(len=20) pure function, public units_abbrev(this)
Definition: unit.F90:223
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
type(unit_t), public unit_kelvin
For converting energies into temperatures.
Explicit interfaces to C functions, defined in write_iter_low.cc.
Definition: write_iter.F90:114
Descriptor of one algorithmic operation.
Definition: algorithm.F90:163
class for a tight binding
Definition: dftb.F90:158
abstract interaction class
surrogate interaction class to avoid circular dependencies between modules.
Abstract class implementing propagators.
Definition: propagator.F90:138
Abstract class for systems.
Definition: system.F90:172
int true(void)
subroutine input()
Definition: vdw.F90:255