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