-
Notifications
You must be signed in to change notification settings - Fork 1
/
cp_control_utils.F
2751 lines (2536 loc) · 143 KB
/
cp_control_utils.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!--------------------------------------------------------------------------------------------------!
! CP2K: A general program to perform molecular dynamics simulations !
! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
! !
! SPDX-License-Identifier: GPL-2.0-or-later !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \brief Utilities to set up the control types
! **************************************************************************************************
MODULE cp_control_utils
USE bibliography, ONLY: &
Andreussi2012, Dewar1977, Dewar1985, Elstner1998, Fattebert2002, Grimme2017, Hu2007, &
Krack2000, Lippert1997, Lippert1999, Porezag1995, Pracht2019, Repasky2002, Rocha2006, &
Schenter2008, Seifert1996, Souza2002, Stengel2009, Stewart1989, Stewart2007, Thiel1992, &
Umari2002, VanVoorhis2015, VandeVondele2005a, VandeVondele2005b, Yin2017, Zhechkov2005, &
cite_reference
USE cp_control_types, ONLY: &
admm_control_create, admm_control_type, ddapc_control_create, ddapc_restraint_type, &
dft_control_create, dft_control_type, efield_type, expot_control_create, &
maxwell_control_create, qs_control_type, tddfpt2_control_type, tddfpt_control_create, &
tddfpt_control_type, xtb_control_type
USE cp_files, ONLY: close_file,&
open_file
USE cp_log_handling, ONLY: cp_get_default_logger,&
cp_logger_type
USE cp_output_handling, ONLY: cp_print_key_finished_output,&
cp_print_key_unit_nr
USE cp_units, ONLY: cp_unit_from_cp2k,&
cp_unit_to_cp2k
USE eeq_input, ONLY: read_eeq_param
USE force_fields_input, ONLY: read_gp_section
USE input_constants, ONLY: &
admm1_type, admm2_type, admmp_type, admmq_type, admms_type, constant_env, custom_env, &
do_admm_aux_exch_func_bee, do_admm_aux_exch_func_bee_libxc, do_admm_aux_exch_func_default, &
do_admm_aux_exch_func_default_libxc, do_admm_aux_exch_func_none, &
do_admm_aux_exch_func_opt, do_admm_aux_exch_func_opt_libxc, do_admm_aux_exch_func_pbex, &
do_admm_aux_exch_func_pbex_libxc, do_admm_aux_exch_func_sx_libxc, &
do_admm_basis_projection, do_admm_blocked_projection, do_admm_blocking_purify_full, &
do_admm_charge_constrained_projection, do_admm_exch_scaling_merlot, &
do_admm_exch_scaling_none, do_admm_purify_cauchy, do_admm_purify_cauchy_subspace, &
do_admm_purify_mcweeny, do_admm_purify_mo_diag, do_admm_purify_mo_no_diag, &
do_admm_purify_none, do_admm_purify_none_dm, do_ddapc_constraint, do_ddapc_restraint, &
do_method_am1, do_method_dftb, do_method_gapw, do_method_gapw_xc, do_method_gpw, &
do_method_lrigpw, do_method_mndo, do_method_mndod, do_method_ofgpw, do_method_pdg, &
do_method_pm3, do_method_pm6, do_method_pm6fm, do_method_pnnl, do_method_rigpw, &
do_method_rm1, do_method_xtb, do_pwgrid_ns_fullspace, do_pwgrid_ns_halfspace, &
do_pwgrid_spherical, do_s2_constraint, do_s2_restraint, do_se_is_kdso, do_se_is_kdso_d, &
do_se_is_slater, do_se_lr_ewald, do_se_lr_ewald_gks, do_se_lr_ewald_r3, do_se_lr_none, &
gapw_1c_large, gapw_1c_medium, gapw_1c_orb, gapw_1c_small, gapw_1c_very_large, &
gaussian_env, no_admm_type, numerical, ramp_env, real_time_propagation, sccs_andreussi, &
sccs_derivative_cd3, sccs_derivative_cd5, sccs_derivative_cd7, sccs_derivative_fft, &
sccs_fattebert_gygi, sic_ad, sic_eo, sic_list_all, sic_list_unpaired, sic_mauri_spz, &
sic_mauri_us, sic_none, slater, tddfpt_dipole_length, tddfpt_excitations, &
tddfpt_kernel_stda, use_mom_ref_user, xtb_vdw_type_d3, xtb_vdw_type_d4, xtb_vdw_type_none
USE input_cp2k_check, ONLY: xc_functionals_expand
USE input_cp2k_dft, ONLY: create_dft_section
USE input_enumeration_types, ONLY: enum_i2c,&
enumeration_type
USE input_keyword_types, ONLY: keyword_get,&
keyword_type
USE input_section_types, ONLY: &
section_get_ival, section_get_keyword, section_release, section_type, section_vals_get, &
section_vals_get_subs_vals, section_vals_type, section_vals_val_get, section_vals_val_set
USE kinds, ONLY: default_path_length,&
default_string_length,&
dp
USE mathconstants, ONLY: fourpi
USE pair_potential_types, ONLY: pair_potential_reallocate
USE periodic_table, ONLY: get_ptable_info
USE qs_cdft_utils, ONLY: read_cdft_control_section
USE smeagol_control_types, ONLY: read_smeagol_control
USE string_utilities, ONLY: uppercase
USE util, ONLY: sort
USE xc, ONLY: xc_uses_kinetic_energy_density,&
xc_uses_norm_drho
USE xc_input_constants, ONLY: xc_deriv_collocate
USE xc_write_output, ONLY: xc_write
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp_control_utils'
PUBLIC :: read_dft_control, &
read_mgrid_section, &
read_qs_section, &
read_tddfpt_control, &
read_tddfpt2_control, &
write_dft_control, &
write_qs_control, &
write_admm_control, &
read_ddapc_section
CONTAINS
! **************************************************************************************************
!> \brief ...
!> \param dft_control ...
!> \param dft_section ...
! **************************************************************************************************
SUBROUTINE read_dft_control(dft_control, dft_section)
TYPE(dft_control_type), POINTER :: dft_control
TYPE(section_vals_type), POINTER :: dft_section
CHARACTER(len=default_path_length) :: basis_set_file_name, potential_file_name
CHARACTER(LEN=default_string_length), &
DIMENSION(:), POINTER :: tmpstringlist
INTEGER :: admmtype, excitations, irep, isize, &
method_id, nrep, xc_deriv_method_id
LOGICAL :: do_hfx, do_ot, do_rpa_admm, do_rtp, &
exopt1, exopt2, exopt3, explicit, &
is_present, l_param, not_SE, &
was_present
REAL(KIND=dp) :: density_cut, gradient_cut, tau_cut
REAL(KIND=dp), DIMENSION(:), POINTER :: pol
TYPE(cp_logger_type), POINTER :: logger
TYPE(section_vals_type), POINTER :: hfx_section, maxwell_section, &
sccs_section, scf_section, &
tmp_section, xc_fun_section, xc_section
was_present = .FALSE.
logger => cp_get_default_logger()
NULLIFY (tmp_section, xc_fun_section, xc_section)
ALLOCATE (dft_control)
CALL dft_control_create(dft_control)
! determine wheather this is a semiempirical or DFTB run
! --> (no XC section needs to be provided)
not_SE = .TRUE.
CALL section_vals_val_get(dft_section, "QS%METHOD", i_val=method_id)
SELECT CASE (method_id)
CASE (do_method_dftb, do_method_xtb, do_method_mndo, do_method_am1, do_method_pm3, do_method_pnnl, &
do_method_pm6, do_method_pm6fm, do_method_pdg, do_method_rm1, do_method_mndod)
not_SE = .FALSE.
END SELECT
! Check for XC section and XC_FUNCTIONAL section
xc_section => section_vals_get_subs_vals(dft_section, "XC")
CALL section_vals_get(xc_section, explicit=is_present)
IF (.NOT. is_present .AND. not_SE) THEN
CPABORT("XC section missing.")
END IF
IF (is_present) THEN
CALL section_vals_val_get(xc_section, "density_cutoff", r_val=density_cut)
CALL section_vals_val_get(xc_section, "gradient_cutoff", r_val=gradient_cut)
CALL section_vals_val_get(xc_section, "tau_cutoff", r_val=tau_cut)
! Perform numerical stability checks and possibly correct the issues
IF (density_cut <= EPSILON(0.0_dp)*100.0_dp) &
CALL cp_warn(__LOCATION__, &
"DENSITY_CUTOFF lower than 100*EPSILON, where EPSILON is the machine precision. "// &
"This may lead to numerical problems. Setting up shake_tol to 100*EPSILON! ")
density_cut = MAX(EPSILON(0.0_dp)*100.0_dp, density_cut)
IF (gradient_cut <= EPSILON(0.0_dp)*100.0_dp) &
CALL cp_warn(__LOCATION__, &
"GRADIENT_CUTOFF lower than 100*EPSILON, where EPSILON is the machine precision. "// &
"This may lead to numerical problems. Setting up shake_tol to 100*EPSILON! ")
gradient_cut = MAX(EPSILON(0.0_dp)*100.0_dp, gradient_cut)
IF (tau_cut <= EPSILON(0.0_dp)*100.0_dp) &
CALL cp_warn(__LOCATION__, &
"TAU_CUTOFF lower than 100*EPSILON, where EPSILON is the machine precision. "// &
"This may lead to numerical problems. Setting up shake_tol to 100*EPSILON! ")
tau_cut = MAX(EPSILON(0.0_dp)*100.0_dp, tau_cut)
CALL section_vals_val_set(xc_section, "density_cutoff", r_val=density_cut)
CALL section_vals_val_set(xc_section, "gradient_cutoff", r_val=gradient_cut)
CALL section_vals_val_set(xc_section, "tau_cutoff", r_val=tau_cut)
END IF
xc_fun_section => section_vals_get_subs_vals(xc_section, "XC_FUNCTIONAL")
CALL section_vals_get(xc_fun_section, explicit=is_present)
IF (.NOT. is_present .AND. not_SE) THEN
CPABORT("XC_FUNCTIONAL section missing.")
END IF
scf_section => section_vals_get_subs_vals(dft_section, "SCF")
CALL section_vals_val_get(dft_section, "UKS", l_val=dft_control%uks)
CALL section_vals_val_get(dft_section, "ROKS", l_val=dft_control%roks)
IF (dft_control%uks .OR. dft_control%roks) THEN
dft_control%nspins = 2
ELSE
dft_control%nspins = 1
END IF
dft_control%lsd = (dft_control%nspins > 1)
dft_control%use_kinetic_energy_density = xc_uses_kinetic_energy_density(xc_fun_section, dft_control%lsd)
xc_deriv_method_id = section_get_ival(xc_section, "XC_GRID%XC_DERIV")
dft_control%drho_by_collocation = (xc_uses_norm_drho(xc_fun_section, dft_control%lsd) &
.AND. (xc_deriv_method_id == xc_deriv_collocate))
IF (dft_control%drho_by_collocation) THEN
CPABORT("derivatives by collocation not implemented")
END IF
! Automatic auxiliary basis set generation
CALL section_vals_val_get(dft_section, "AUTO_BASIS", n_rep_val=nrep)
DO irep = 1, nrep
CALL section_vals_val_get(dft_section, "AUTO_BASIS", i_rep_val=irep, c_vals=tmpstringlist)
IF (SIZE(tmpstringlist) == 2) THEN
CALL uppercase(tmpstringlist(2))
SELECT CASE (tmpstringlist(2))
CASE ("X")
isize = -1
CASE ("SMALL")
isize = 0
CASE ("MEDIUM")
isize = 1
CASE ("LARGE")
isize = 2
CASE ("HUGE")
isize = 3
CASE DEFAULT
CPWARN("Unknown basis size in AUTO_BASIS keyword:"//TRIM(tmpstringlist(1)))
END SELECT
!
SELECT CASE (tmpstringlist(1))
CASE ("X")
CASE ("RI_AUX")
dft_control%auto_basis_ri_aux = isize
CASE ("AUX_FIT")
dft_control%auto_basis_aux_fit = isize
CASE ("LRI_AUX")
dft_control%auto_basis_lri_aux = isize
CASE ("P_LRI_AUX")
dft_control%auto_basis_p_lri_aux = isize
CASE ("RI_HXC")
dft_control%auto_basis_ri_hxc = isize
CASE ("RI_XAS")
dft_control%auto_basis_ri_xas = isize
CASE ("RI_HFX")
dft_control%auto_basis_ri_hfx = isize
CASE DEFAULT
CPWARN("Unknown basis type in AUTO_BASIS keyword:"//TRIM(tmpstringlist(1)))
END SELECT
ELSE
CALL cp_abort(__LOCATION__, &
"AUTO_BASIS keyword in &DFT section has a wrong number of arguments.")
END IF
END DO
!! check if we do wavefunction fitting
tmp_section => section_vals_get_subs_vals(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD")
CALL section_vals_get(tmp_section, explicit=is_present)
!
hfx_section => section_vals_get_subs_vals(xc_section, "HF")
CALL section_vals_get(hfx_section, explicit=do_hfx)
CALL section_vals_val_get(xc_section, "WF_CORRELATION%RI_RPA%ADMM", l_val=do_rpa_admm)
is_present = is_present .AND. (do_hfx .OR. do_rpa_admm)
!
dft_control%do_admm = is_present
dft_control%do_admm_mo = .FALSE.
dft_control%do_admm_dm = .FALSE.
IF (is_present) THEN
do_ot = .FALSE.
CALL section_vals_val_get(scf_section, "OT%_SECTION_PARAMETERS_", l_val=do_ot)
CALL admm_control_create(dft_control%admm_control)
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%ADMM_TYPE", i_val=admmtype)
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%ADMM_PURIFICATION_METHOD", explicit=exopt1)
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%METHOD", explicit=exopt2)
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%EXCH_SCALING_MODEL", explicit=exopt3)
dft_control%admm_control%admm_type = admmtype
SELECT CASE (admmtype)
CASE (no_admm_type)
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%ADMM_PURIFICATION_METHOD", i_val=method_id)
dft_control%admm_control%purification_method = method_id
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%METHOD", i_val=method_id)
dft_control%admm_control%method = method_id
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%EXCH_SCALING_MODEL", i_val=method_id)
dft_control%admm_control%scaling_model = method_id
CASE (admm1_type)
! METHOD BASIS_PROJECTION
! ADMM_PURIFICATION_METHOD choose
! EXCH_SCALING_MODEL NONE
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%ADMM_PURIFICATION_METHOD", i_val=method_id)
dft_control%admm_control%purification_method = method_id
dft_control%admm_control%method = do_admm_basis_projection
dft_control%admm_control%scaling_model = do_admm_exch_scaling_none
CASE (admm2_type)
! METHOD BASIS_PROJECTION
! ADMM_PURIFICATION_METHOD NONE
! EXCH_SCALING_MODEL NONE
dft_control%admm_control%purification_method = do_admm_purify_none
dft_control%admm_control%method = do_admm_basis_projection
dft_control%admm_control%scaling_model = do_admm_exch_scaling_none
CASE (admms_type)
! ADMM_PURIFICATION_METHOD NONE
! METHOD CHARGE_CONSTRAINED_PROJECTION
! EXCH_SCALING_MODEL MERLOT
dft_control%admm_control%purification_method = do_admm_purify_none
dft_control%admm_control%method = do_admm_charge_constrained_projection
dft_control%admm_control%scaling_model = do_admm_exch_scaling_merlot
CASE (admmp_type)
! ADMM_PURIFICATION_METHOD NONE
! METHOD BASIS_PROJECTION
! EXCH_SCALING_MODEL MERLOT
dft_control%admm_control%purification_method = do_admm_purify_none
dft_control%admm_control%method = do_admm_basis_projection
dft_control%admm_control%scaling_model = do_admm_exch_scaling_merlot
CASE (admmq_type)
! ADMM_PURIFICATION_METHOD NONE
! METHOD CHARGE_CONSTRAINED_PROJECTION
! EXCH_SCALING_MODEL NONE
dft_control%admm_control%purification_method = do_admm_purify_none
dft_control%admm_control%method = do_admm_charge_constrained_projection
dft_control%admm_control%scaling_model = do_admm_exch_scaling_none
CASE DEFAULT
CALL cp_abort(__LOCATION__, &
"ADMM_TYPE keyword in &AUXILIARY_DENSITY_MATRIX_METHOD section has a wrong value.")
END SELECT
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%EPS_FILTER", &
r_val=dft_control%admm_control%eps_filter)
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%EXCH_CORRECTION_FUNC", i_val=method_id)
dft_control%admm_control%aux_exch_func = method_id
! parameters for X functional
dft_control%admm_control%aux_exch_func_param = .FALSE.
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%OPTX_A1", explicit=explicit, &
r_val=dft_control%admm_control%aux_x_param(1))
IF (explicit) dft_control%admm_control%aux_exch_func_param = .TRUE.
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%OPTX_A2", explicit=explicit, &
r_val=dft_control%admm_control%aux_x_param(2))
IF (explicit) dft_control%admm_control%aux_exch_func_param = .TRUE.
CALL section_vals_val_get(dft_section, "AUXILIARY_DENSITY_MATRIX_METHOD%OPTX_GAMMA", explicit=explicit, &
r_val=dft_control%admm_control%aux_x_param(3))
IF (explicit) dft_control%admm_control%aux_exch_func_param = .TRUE.
CALL read_admm_block_list(dft_control%admm_control, dft_section)
! check for double assignments
SELECT CASE (admmtype)
CASE (admm2_type)
IF (exopt2) CALL cp_warn(__LOCATION__, &
"Value of ADMM_PURIFICATION_METHOD keyword will be overwritten with ADMM_TYPE selections.")
IF (exopt3) CALL cp_warn(__LOCATION__, &
"Value of EXCH_SCALING_MODEL keyword will be overwritten with ADMM_TYPE selections.")
CASE (admm1_type, admms_type, admmp_type, admmq_type)
IF (exopt1) CALL cp_warn(__LOCATION__, &
"Value of METHOD keyword will be overwritten with ADMM_TYPE selections.")
IF (exopt2) CALL cp_warn(__LOCATION__, &
"Value of METHOD keyword will be overwritten with ADMM_TYPE selections.")
IF (exopt3) CALL cp_warn(__LOCATION__, &
"Value of EXCH_SCALING_MODEL keyword will be overwritten with ADMM_TYPE selections.")
END SELECT
! In the case of charge-constrained projection (e.g. according to Merlot),
! there is no purification needed and hence, do_admm_purify_none has to be set.
IF ((dft_control%admm_control%method == do_admm_blocking_purify_full .OR. &
dft_control%admm_control%method == do_admm_blocked_projection) &
.AND. dft_control%admm_control%scaling_model == do_admm_exch_scaling_merlot) THEN
CPABORT("ADMM: Blocking and Merlot scaling are mutually exclusive.")
END IF
IF (dft_control%admm_control%method == do_admm_charge_constrained_projection .AND. &
dft_control%admm_control%purification_method /= do_admm_purify_none) THEN
CALL cp_abort(__LOCATION__, &
"ADMM: In the case of METHOD=CHARGE_CONSTRAINED_PROJECTION, "// &
"ADMM_PURIFICATION_METHOD=NONE has to be set.")
END IF
IF (dft_control%admm_control%purification_method == do_admm_purify_mo_diag .OR. &
dft_control%admm_control%purification_method == do_admm_purify_mo_no_diag) THEN
IF (dft_control%admm_control%method /= do_admm_basis_projection) &
CPABORT("ADMM: Chosen purification requires BASIS_PROJECTION")
IF (.NOT. do_ot) CPABORT("ADMM: MO-based purification requires OT.")
END IF
IF (dft_control%admm_control%purification_method == do_admm_purify_none_dm .OR. &
dft_control%admm_control%purification_method == do_admm_purify_mcweeny) THEN
dft_control%do_admm_dm = .TRUE.
ELSE
dft_control%do_admm_mo = .TRUE.
END IF
END IF
! Set restricted to true, if both OT and ROKS are requested
!MK in principle dft_control%restricted could be dropped completely like the
!MK input key by using only dft_control%roks now
CALL section_vals_val_get(scf_section, "OT%_SECTION_PARAMETERS_", l_val=l_param)
dft_control%restricted = (dft_control%roks .AND. l_param)
CALL section_vals_val_get(dft_section, "CHARGE", i_val=dft_control%charge)
CALL section_vals_val_get(dft_section, "MULTIPLICITY", i_val=dft_control%multiplicity)
CALL section_vals_val_get(dft_section, "RELAX_MULTIPLICITY", r_val=dft_control%relax_multiplicity)
IF (dft_control%relax_multiplicity > 0.0_dp) THEN
IF (.NOT. dft_control%uks) &
CALL cp_abort(__LOCATION__, "The option RELAX_MULTIPLICITY is only valid for "// &
"unrestricted Kohn-Sham (UKS) calculations")
END IF
! check for the presence of the low spin roks section
tmp_section => section_vals_get_subs_vals(dft_section, "LOW_SPIN_ROKS")
CALL section_vals_get(tmp_section, explicit=dft_control%low_spin_roks)
dft_control%sic_method_id = sic_none
dft_control%sic_scaling_a = 1.0_dp
dft_control%sic_scaling_b = 1.0_dp
! DFT+U
dft_control%dft_plus_u = .FALSE.
CALL section_vals_val_get(dft_section, "PLUS_U_METHOD", i_val=method_id)
dft_control%plus_u_method_id = method_id
! Smearing in use
dft_control%smear = .FALSE.
! Surface dipole correction
dft_control%correct_surf_dip = .FALSE.
CALL section_vals_val_get(dft_section, "SURFACE_DIPOLE_CORRECTION", l_val=dft_control%correct_surf_dip)
CALL section_vals_val_get(dft_section, "SURF_DIP_DIR", i_val=dft_control%dir_surf_dip)
dft_control%pos_dir_surf_dip = -1.0_dp
CALL section_vals_val_get(dft_section, "SURF_DIP_POS", r_val=dft_control%pos_dir_surf_dip)
! another logical variable, surf_dip_correct_switch, is introduced for
! implementation of "SURF_DIP_SWITCH" [SGh]
dft_control%switch_surf_dip = .FALSE.
dft_control%surf_dip_correct_switch = dft_control%correct_surf_dip
CALL section_vals_val_get(dft_section, "SURF_DIP_SWITCH", l_val=dft_control%switch_surf_dip)
dft_control%correct_el_density_dip = .FALSE.
CALL section_vals_val_get(dft_section, "CORE_CORR_DIP", l_val=dft_control%correct_el_density_dip)
IF (dft_control%correct_el_density_dip) THEN
IF (dft_control%correct_surf_dip) THEN
! Do nothing, move on
ELSE
dft_control%correct_el_density_dip = .FALSE.
CPWARN("CORE_CORR_DIP keyword is activated only if SURFACE_DIPOLE_CORRECTION is TRUE")
END IF
END IF
CALL section_vals_val_get(dft_section, "BASIS_SET_FILE_NAME", &
c_val=basis_set_file_name)
CALL section_vals_val_get(dft_section, "POTENTIAL_FILE_NAME", &
c_val=potential_file_name)
! Read the input section
tmp_section => section_vals_get_subs_vals(dft_section, "sic")
CALL section_vals_val_get(tmp_section, "SIC_METHOD", &
i_val=dft_control%sic_method_id)
CALL section_vals_val_get(tmp_section, "ORBITAL_SET", &
i_val=dft_control%sic_list_id)
CALL section_vals_val_get(tmp_section, "SIC_SCALING_A", &
r_val=dft_control%sic_scaling_a)
CALL section_vals_val_get(tmp_section, "SIC_SCALING_B", &
r_val=dft_control%sic_scaling_b)
! Determine if this is a TDDFPT run
CALL section_vals_val_get(dft_section, "EXCITATIONS", i_val=excitations)
dft_control%do_tddfpt_calculation = (excitations == tddfpt_excitations)
IF (dft_control%do_tddfpt_calculation) THEN
CALL tddfpt_control_create(dft_control%tddfpt_control)
END IF
do_rtp = .FALSE.
tmp_section => section_vals_get_subs_vals(dft_section, "REAL_TIME_PROPAGATION")
CALL section_vals_get(tmp_section, explicit=is_present)
IF (is_present) THEN
CALL read_rtp_section(dft_control, tmp_section)
do_rtp = .TRUE.
END IF
! Read the input section
tmp_section => section_vals_get_subs_vals(dft_section, "XAS")
CALL section_vals_get(tmp_section, explicit=dft_control%do_xas_calculation)
IF (dft_control%do_xas_calculation) THEN
! Override with section parameter
CALL section_vals_val_get(tmp_section, "_SECTION_PARAMETERS_", &
l_val=dft_control%do_xas_calculation)
END IF
tmp_section => section_vals_get_subs_vals(dft_section, "XAS_TDP")
CALL section_vals_get(tmp_section, explicit=dft_control%do_xas_tdp_calculation)
IF (dft_control%do_xas_tdp_calculation) THEN
! Override with section parameter
CALL section_vals_val_get(tmp_section, "_SECTION_PARAMETERS_", &
l_val=dft_control%do_xas_tdp_calculation)
END IF
! Read the finite field input section
dft_control%apply_efield = .FALSE.
dft_control%apply_efield_field = .FALSE. !this is for RTP
dft_control%apply_vector_potential = .FALSE. !this is for RTP
tmp_section => section_vals_get_subs_vals(dft_section, "EFIELD")
CALL section_vals_get(tmp_section, n_repetition=nrep, explicit=is_present)
IF (is_present) THEN
ALLOCATE (dft_control%efield_fields(nrep))
CALL read_efield_sections(dft_control, tmp_section)
IF (do_rtp) THEN
IF (.NOT. dft_control%rtp_control%velocity_gauge) THEN
dft_control%apply_efield_field = .TRUE.
ELSE
dft_control%apply_vector_potential = .TRUE.
! Use this input value of vector potential to (re)start RTP
dft_control%rtp_control%vec_pot = dft_control%efield_fields(1)%efield%vec_pot_initial
END IF
ELSE
dft_control%apply_efield = .TRUE.
CPASSERT(nrep == 1)
END IF
END IF
! Read the finite field input section for periodic fields
tmp_section => section_vals_get_subs_vals(dft_section, "PERIODIC_EFIELD")
CALL section_vals_get(tmp_section, explicit=dft_control%apply_period_efield)
IF (dft_control%apply_period_efield) THEN
ALLOCATE (dft_control%period_efield)
CALL section_vals_val_get(tmp_section, "POLARISATION", r_vals=pol)
dft_control%period_efield%polarisation(1:3) = pol(1:3)
CALL section_vals_val_get(tmp_section, "D_FILTER", r_vals=pol)
dft_control%period_efield%d_filter(1:3) = pol(1:3)
CALL section_vals_val_get(tmp_section, "INTENSITY", &
r_val=dft_control%period_efield%strength)
dft_control%period_efield%displacement_field = .FALSE.
CALL section_vals_val_get(tmp_section, "DISPLACEMENT_FIELD", &
l_val=dft_control%period_efield%displacement_field)
! periodic fields don't work with RTP
CPASSERT(.NOT. do_rtp)
IF (dft_control%period_efield%displacement_field) THEN
CALL cite_reference(Stengel2009)
ELSE
CALL cite_reference(Souza2002)
CALL cite_reference(Umari2002)
END IF
END IF
! Read the external potential input section
tmp_section => section_vals_get_subs_vals(dft_section, "EXTERNAL_POTENTIAL")
CALL section_vals_get(tmp_section, explicit=dft_control%apply_external_potential)
IF (dft_control%apply_external_potential) THEN
CALL expot_control_create(dft_control%expot_control)
CALL section_vals_val_get(tmp_section, "READ_FROM_CUBE", &
l_val=dft_control%expot_control%read_from_cube)
CALL section_vals_val_get(tmp_section, "STATIC", &
l_val=dft_control%expot_control%static)
CALL section_vals_val_get(tmp_section, "SCALING_FACTOR", &
r_val=dft_control%expot_control%scaling_factor)
! External potential using Maxwell equation
maxwell_section => section_vals_get_subs_vals(tmp_section, "MAXWELL")
CALL section_vals_get(maxwell_section, explicit=is_present)
IF (is_present) THEN
dft_control%expot_control%maxwell_solver = .TRUE.
CALL maxwell_control_create(dft_control%maxwell_control)
! read the input values from Maxwell section
CALL section_vals_val_get(maxwell_section, "TEST_REAL", &
r_val=dft_control%maxwell_control%real_test)
CALL section_vals_val_get(maxwell_section, "TEST_INTEGER", &
i_val=dft_control%maxwell_control%int_test)
CALL section_vals_val_get(maxwell_section, "TEST_LOGICAL", &
l_val=dft_control%maxwell_control%log_test)
ELSE
dft_control%expot_control%maxwell_solver = .FALSE.
END IF
END IF
! Read the SCCS input section if present
sccs_section => section_vals_get_subs_vals(dft_section, "SCCS")
CALL section_vals_get(sccs_section, explicit=is_present)
IF (is_present) THEN
! Check section parameter if SCCS is activated
CALL section_vals_val_get(sccs_section, "_SECTION_PARAMETERS_", &
l_val=dft_control%do_sccs)
IF (dft_control%do_sccs) THEN
ALLOCATE (dft_control%sccs_control)
CALL section_vals_val_get(sccs_section, "RELATIVE_PERMITTIVITY", &
r_val=dft_control%sccs_control%epsilon_solvent)
CALL section_vals_val_get(sccs_section, "ALPHA", &
r_val=dft_control%sccs_control%alpha_solvent)
CALL section_vals_val_get(sccs_section, "BETA", &
r_val=dft_control%sccs_control%beta_solvent)
CALL section_vals_val_get(sccs_section, "DELTA_RHO", &
r_val=dft_control%sccs_control%delta_rho)
CALL section_vals_val_get(sccs_section, "DERIVATIVE_METHOD", &
i_val=dft_control%sccs_control%derivative_method)
CALL section_vals_val_get(sccs_section, "METHOD", &
i_val=dft_control%sccs_control%method_id)
CALL section_vals_val_get(sccs_section, "EPS_SCCS", &
r_val=dft_control%sccs_control%eps_sccs)
CALL section_vals_val_get(sccs_section, "EPS_SCF", &
r_val=dft_control%sccs_control%eps_scf)
CALL section_vals_val_get(sccs_section, "GAMMA", &
r_val=dft_control%sccs_control%gamma_solvent)
CALL section_vals_val_get(sccs_section, "MAX_ITER", &
i_val=dft_control%sccs_control%max_iter)
CALL section_vals_val_get(sccs_section, "MIXING", &
r_val=dft_control%sccs_control%mixing)
SELECT CASE (dft_control%sccs_control%method_id)
CASE (sccs_andreussi)
tmp_section => section_vals_get_subs_vals(sccs_section, "ANDREUSSI")
CALL section_vals_val_get(tmp_section, "RHO_MAX", &
r_val=dft_control%sccs_control%rho_max)
CALL section_vals_val_get(tmp_section, "RHO_MIN", &
r_val=dft_control%sccs_control%rho_min)
IF (dft_control%sccs_control%rho_max < dft_control%sccs_control%rho_min) THEN
CALL cp_abort(__LOCATION__, &
"The SCCS parameter RHO_MAX is smaller than RHO_MIN. "// &
"Please, check your input!")
END IF
CALL cite_reference(Andreussi2012)
CASE (sccs_fattebert_gygi)
tmp_section => section_vals_get_subs_vals(sccs_section, "FATTEBERT-GYGI")
CALL section_vals_val_get(tmp_section, "BETA", &
r_val=dft_control%sccs_control%beta)
IF (dft_control%sccs_control%beta < 0.5_dp) THEN
CALL cp_abort(__LOCATION__, &
"A value smaller than 0.5 for the SCCS parameter beta "// &
"causes numerical problems. Please, check your input!")
END IF
CALL section_vals_val_get(tmp_section, "RHO_ZERO", &
r_val=dft_control%sccs_control%rho_zero)
CALL cite_reference(Fattebert2002)
CASE DEFAULT
CPABORT("Invalid SCCS model specified. Please, check your input!")
END SELECT
CALL cite_reference(Yin2017)
END IF
END IF
! ZMP added input sections
! Read the external density input section
tmp_section => section_vals_get_subs_vals(dft_section, "EXTERNAL_DENSITY")
CALL section_vals_get(tmp_section, explicit=dft_control%apply_external_density)
! Read the external vxc input section
tmp_section => section_vals_get_subs_vals(dft_section, "EXTERNAL_VXC")
CALL section_vals_get(tmp_section, explicit=dft_control%apply_external_vxc)
! SMEAGOL interface
tmp_section => section_vals_get_subs_vals(dft_section, "SMEAGOL")
CALL read_smeagol_control(dft_control%smeagol_control, tmp_section)
END SUBROUTINE read_dft_control
! **************************************************************************************************
!> \brief ...
!> \param qs_control ...
!> \param dft_section ...
! **************************************************************************************************
SUBROUTINE read_mgrid_section(qs_control, dft_section)
TYPE(qs_control_type), INTENT(INOUT) :: qs_control
TYPE(section_vals_type), POINTER :: dft_section
CHARACTER(len=*), PARAMETER :: routineN = 'read_mgrid_section'
INTEGER :: handle, igrid_level, ngrid_level
LOGICAL :: explicit, multigrid_set
REAL(dp) :: cutoff
REAL(dp), DIMENSION(:), POINTER :: cutofflist
TYPE(section_vals_type), POINTER :: mgrid_section
CALL timeset(routineN, handle)
NULLIFY (mgrid_section, cutofflist)
mgrid_section => section_vals_get_subs_vals(dft_section, "MGRID")
CALL section_vals_val_get(mgrid_section, "NGRIDS", i_val=ngrid_level)
CALL section_vals_val_get(mgrid_section, "MULTIGRID_SET", l_val=multigrid_set)
CALL section_vals_val_get(mgrid_section, "CUTOFF", r_val=cutoff)
CALL section_vals_val_get(mgrid_section, "PROGRESSION_FACTOR", r_val=qs_control%progression_factor)
CALL section_vals_val_get(mgrid_section, "COMMENSURATE", l_val=qs_control%commensurate_mgrids)
CALL section_vals_val_get(mgrid_section, "REALSPACE", l_val=qs_control%realspace_mgrids)
CALL section_vals_val_get(mgrid_section, "REL_CUTOFF", r_val=qs_control%relative_cutoff)
CALL section_vals_val_get(mgrid_section, "SKIP_LOAD_BALANCE_DISTRIBUTED", &
l_val=qs_control%skip_load_balance_distributed)
! For SE and DFTB possibly override with new defaults
IF (qs_control%semi_empirical .OR. qs_control%dftb .OR. qs_control%xtb) THEN
ngrid_level = 1
multigrid_set = .FALSE.
! Override default cutoff value unless user specified an explicit argument..
CALL section_vals_val_get(mgrid_section, "CUTOFF", explicit=explicit, r_val=cutoff)
IF (.NOT. explicit) cutoff = 1.0_dp
END IF
ALLOCATE (qs_control%e_cutoff(ngrid_level))
qs_control%cutoff = cutoff
IF (multigrid_set) THEN
! Read the values from input
IF (qs_control%commensurate_mgrids) THEN
CPABORT("Do not specify cutoffs for the commensurate grids (NYI)")
END IF
CALL section_vals_val_get(mgrid_section, "MULTIGRID_CUTOFF", r_vals=cutofflist)
IF (ASSOCIATED(cutofflist)) THEN
IF (SIZE(cutofflist, 1) /= ngrid_level) THEN
CPABORT("Number of multi-grids requested and number of cutoff values do not match")
END IF
DO igrid_level = 1, ngrid_level
qs_control%e_cutoff(igrid_level) = cutofflist(igrid_level)
END DO
END IF
! set cutoff to smallest value in multgrid available with >= cutoff
DO igrid_level = ngrid_level, 1, -1
IF (qs_control%cutoff <= qs_control%e_cutoff(igrid_level)) THEN
qs_control%cutoff = qs_control%e_cutoff(igrid_level)
EXIT
END IF
! set largest grid value to cutoff
IF (igrid_level == 1) THEN
qs_control%cutoff = qs_control%e_cutoff(1)
END IF
END DO
ELSE
IF (qs_control%commensurate_mgrids) qs_control%progression_factor = 4.0_dp
qs_control%e_cutoff(1) = qs_control%cutoff
DO igrid_level = 2, ngrid_level
qs_control%e_cutoff(igrid_level) = qs_control%e_cutoff(igrid_level - 1)/ &
qs_control%progression_factor
END DO
END IF
! check that multigrids are ordered
DO igrid_level = 2, ngrid_level
IF (qs_control%e_cutoff(igrid_level) > qs_control%e_cutoff(igrid_level - 1)) THEN
CPABORT("The cutoff values for the multi-grids are not ordered from large to small")
ELSE IF (qs_control%e_cutoff(igrid_level) == qs_control%e_cutoff(igrid_level - 1)) THEN
CPABORT("The same cutoff value was specified for two multi-grids")
END IF
END DO
CALL timestop(handle)
END SUBROUTINE read_mgrid_section
! **************************************************************************************************
!> \brief ...
!> \param qs_control ...
!> \param qs_section ...
! **************************************************************************************************
SUBROUTINE read_qs_section(qs_control, qs_section)
TYPE(qs_control_type), INTENT(INOUT) :: qs_control
TYPE(section_vals_type), POINTER :: qs_section
CHARACTER(len=*), PARAMETER :: routineN = 'read_qs_section'
CHARACTER(LEN=default_string_length) :: cval
CHARACTER(LEN=default_string_length), &
DIMENSION(:), POINTER :: clist
INTEGER :: handle, itmp, j, jj, k, n_rep, n_var, &
ngauss, ngp, nrep
INTEGER, DIMENSION(:), POINTER :: tmplist
LOGICAL :: explicit, was_present
REAL(dp) :: tmp, tmpsqrt, value
REAL(dp), POINTER :: scal(:)
TYPE(section_vals_type), POINTER :: cdft_control_section, ddapc_restraint_section, &
dftb_parameter, dftb_section, eeq_section, genpot_section, lri_optbas_section, &
mull_section, nonbonded_section, s2_restraint_section, se_section, xtb_parameter, &
xtb_section
CALL timeset(routineN, handle)
was_present = .FALSE.
NULLIFY (mull_section, ddapc_restraint_section, s2_restraint_section, &
se_section, dftb_section, xtb_section, dftb_parameter, xtb_parameter, lri_optbas_section, &
cdft_control_section, genpot_section, eeq_section)
mull_section => section_vals_get_subs_vals(qs_section, "MULLIKEN_RESTRAINT")
ddapc_restraint_section => section_vals_get_subs_vals(qs_section, "DDAPC_RESTRAINT")
s2_restraint_section => section_vals_get_subs_vals(qs_section, "S2_RESTRAINT")
se_section => section_vals_get_subs_vals(qs_section, "SE")
dftb_section => section_vals_get_subs_vals(qs_section, "DFTB")
xtb_section => section_vals_get_subs_vals(qs_section, "xTB")
dftb_parameter => section_vals_get_subs_vals(dftb_section, "PARAMETER")
xtb_parameter => section_vals_get_subs_vals(xtb_section, "PARAMETER")
eeq_section => section_vals_get_subs_vals(xtb_section, "EEQ")
lri_optbas_section => section_vals_get_subs_vals(qs_section, "OPTIMIZE_LRI_BASIS")
cdft_control_section => section_vals_get_subs_vals(qs_section, "CDFT")
nonbonded_section => section_vals_get_subs_vals(xtb_section, "NONBONDED")
genpot_section => section_vals_get_subs_vals(nonbonded_section, "GENPOT")
! Setup all defaults values and overwrite input parameters
! EPS_DEFAULT should set the target accuracy in the total energy (~per electron) or a closely related value
CALL section_vals_val_get(qs_section, "EPS_DEFAULT", r_val=value)
tmpsqrt = SQRT(value) ! a trick to work around a NAG 5.1 optimizer bug
! random choice ?
qs_control%eps_core_charge = value/100.0_dp
! correct if all Gaussians would have the same radius (overlap will be smaller than eps_pgf_orb**2).
! Can be significantly in error if not... requires fully new screening/pairlist procedures
qs_control%eps_pgf_orb = tmpsqrt
qs_control%eps_kg_orb = qs_control%eps_pgf_orb
! consistent since also a kind of overlap
qs_control%eps_ppnl = qs_control%eps_pgf_orb/100.0_dp
! accuracy is basically set by the overlap, this sets an empirical shift
qs_control%eps_ppl = 1.0E-2_dp
!
qs_control%gapw_control%eps_cpc = value
! expexted error in the density
qs_control%eps_rho_gspace = value
qs_control%eps_rho_rspace = value
! error in the gradient, can be the sqrt of the error in the energy, ignored if map_consistent
qs_control%eps_gvg_rspace = tmpsqrt
!
CALL section_vals_val_get(qs_section, "EPS_CORE_CHARGE", n_rep_val=n_rep)
IF (n_rep /= 0) THEN
CALL section_vals_val_get(qs_section, "EPS_CORE_CHARGE", r_val=qs_control%eps_core_charge)
END IF
CALL section_vals_val_get(qs_section, "EPS_GVG_RSPACE", n_rep_val=n_rep)
IF (n_rep /= 0) THEN
CALL section_vals_val_get(qs_section, "EPS_GVG_RSPACE", r_val=qs_control%eps_gvg_rspace)
END IF
CALL section_vals_val_get(qs_section, "EPS_PGF_ORB", n_rep_val=n_rep)
IF (n_rep /= 0) THEN
CALL section_vals_val_get(qs_section, "EPS_PGF_ORB", r_val=qs_control%eps_pgf_orb)
END IF
CALL section_vals_val_get(qs_section, "EPS_KG_ORB", n_rep_val=n_rep)
IF (n_rep /= 0) THEN
CALL section_vals_val_get(qs_section, "EPS_KG_ORB", r_val=tmp)
qs_control%eps_kg_orb = SQRT(tmp)
END IF
CALL section_vals_val_get(qs_section, "EPS_PPL", n_rep_val=n_rep)
IF (n_rep /= 0) THEN
CALL section_vals_val_get(qs_section, "EPS_PPL", r_val=qs_control%eps_ppl)
END IF
CALL section_vals_val_get(qs_section, "EPS_PPNL", n_rep_val=n_rep)
IF (n_rep /= 0) THEN
CALL section_vals_val_get(qs_section, "EPS_PPNL", r_val=qs_control%eps_ppnl)
END IF
CALL section_vals_val_get(qs_section, "EPS_RHO", n_rep_val=n_rep)
IF (n_rep /= 0) THEN
CALL section_vals_val_get(qs_section, "EPS_RHO", r_val=qs_control%eps_rho_gspace)
qs_control%eps_rho_rspace = qs_control%eps_rho_gspace
END IF
CALL section_vals_val_get(qs_section, "EPS_RHO_RSPACE", n_rep_val=n_rep)
IF (n_rep /= 0) THEN
CALL section_vals_val_get(qs_section, "EPS_RHO_RSPACE", r_val=qs_control%eps_rho_rspace)
END IF
CALL section_vals_val_get(qs_section, "EPS_RHO_GSPACE", n_rep_val=n_rep)
IF (n_rep /= 0) THEN
CALL section_vals_val_get(qs_section, "EPS_RHO_GSPACE", r_val=qs_control%eps_rho_gspace)
END IF
CALL section_vals_val_get(qs_section, "EPS_FILTER_MATRIX", n_rep_val=n_rep)
IF (n_rep /= 0) THEN
CALL section_vals_val_get(qs_section, "EPS_FILTER_MATRIX", r_val=qs_control%eps_filter_matrix)
END IF
CALL section_vals_val_get(qs_section, "EPS_CPC", n_rep_val=n_rep)
IF (n_rep /= 0) THEN
CALL section_vals_val_get(qs_section, "EPS_CPC", r_val=qs_control%gapw_control%eps_cpc)
END IF
CALL section_vals_val_get(qs_section, "EPSFIT", r_val=qs_control%gapw_control%eps_fit)
CALL section_vals_val_get(qs_section, "EPSISO", r_val=qs_control%gapw_control%eps_iso)
CALL section_vals_val_get(qs_section, "EPSSVD", r_val=qs_control%gapw_control%eps_svd)
CALL section_vals_val_get(qs_section, "EPSRHO0", r_val=qs_control%gapw_control%eps_Vrho0)
CALL section_vals_val_get(qs_section, "ALPHA0_HARD", r_val=qs_control%gapw_control%alpha0_hard)
qs_control%gapw_control%lrho1_eq_lrho0 = .FALSE.
qs_control%gapw_control%alpha0_hard_from_input = .FALSE.
IF (qs_control%gapw_control%alpha0_hard /= 0.0_dp) qs_control%gapw_control%alpha0_hard_from_input = .TRUE.
CALL section_vals_val_get(qs_section, "FORCE_PAW", l_val=qs_control%gapw_control%force_paw)
CALL section_vals_val_get(qs_section, "MAX_RAD_LOCAL", r_val=qs_control%gapw_control%max_rad_local)
CALL section_vals_val_get(qs_section, "MIN_PAIR_LIST_RADIUS", r_val=qs_control%pairlist_radius)
CALL section_vals_val_get(qs_section, "LS_SCF", l_val=qs_control%do_ls_scf)
CALL section_vals_val_get(qs_section, "ALMO_SCF", l_val=qs_control%do_almo_scf)
CALL section_vals_val_get(qs_section, "KG_METHOD", l_val=qs_control%do_kg)
! Logicals
CALL section_vals_val_get(qs_section, "REF_EMBED_SUBSYS", l_val=qs_control%ref_embed_subsys)
CALL section_vals_val_get(qs_section, "CLUSTER_EMBED_SUBSYS", l_val=qs_control%cluster_embed_subsys)
CALL section_vals_val_get(qs_section, "HIGH_LEVEL_EMBED_SUBSYS", l_val=qs_control%high_level_embed_subsys)
CALL section_vals_val_get(qs_section, "DFET_EMBEDDED", l_val=qs_control%dfet_embedded)
CALL section_vals_val_get(qs_section, "DMFET_EMBEDDED", l_val=qs_control%dmfet_embedded)
! Integers gapw
CALL section_vals_val_get(qs_section, "LMAXN1", i_val=qs_control%gapw_control%lmax_sphere)
CALL section_vals_val_get(qs_section, "LMAXN0", i_val=qs_control%gapw_control%lmax_rho0)
CALL section_vals_val_get(qs_section, "LADDN0", i_val=qs_control%gapw_control%ladd_rho0)
CALL section_vals_val_get(qs_section, "QUADRATURE", i_val=qs_control%gapw_control%quadrature)
! GAPW 1c basis
CALL section_vals_val_get(qs_section, "GAPW_1C_BASIS", i_val=qs_control%gapw_control%basis_1c)
IF (qs_control%gapw_control%basis_1c /= gapw_1c_orb) THEN
qs_control%gapw_control%eps_svd = MAX(qs_control%gapw_control%eps_svd, 1.E-12_dp)
END IF
! Integers grids
CALL section_vals_val_get(qs_section, "PW_GRID", i_val=itmp)
SELECT CASE (itmp)
CASE (do_pwgrid_spherical)
qs_control%pw_grid_opt%spherical = .TRUE.
qs_control%pw_grid_opt%fullspace = .FALSE.
CASE (do_pwgrid_ns_fullspace)
qs_control%pw_grid_opt%spherical = .FALSE.
qs_control%pw_grid_opt%fullspace = .TRUE.
CASE (do_pwgrid_ns_halfspace)
qs_control%pw_grid_opt%spherical = .FALSE.
qs_control%pw_grid_opt%fullspace = .FALSE.
END SELECT
! Method for PPL calculation
CALL section_vals_val_get(qs_section, "CORE_PPL", i_val=itmp)
qs_control%do_ppl_method = itmp
CALL section_vals_val_get(qs_section, "PW_GRID_LAYOUT", i_vals=tmplist)
qs_control%pw_grid_opt%distribution_layout = tmplist
CALL section_vals_val_get(qs_section, "PW_GRID_BLOCKED", i_val=qs_control%pw_grid_opt%blocked)
!Integers extrapolation
CALL section_vals_val_get(qs_section, "EXTRAPOLATION", i_val=qs_control%wf_interpolation_method_nr)
CALL section_vals_val_get(qs_section, "EXTRAPOLATION_ORDER", i_val=qs_control%wf_extrapolation_order)
!Method
CALL section_vals_val_get(qs_section, "METHOD", i_val=qs_control%method_id)
qs_control%gapw = .FALSE.
qs_control%gapw_xc = .FALSE.
qs_control%gpw = .FALSE.
qs_control%pao = .FALSE.
qs_control%dftb = .FALSE.
qs_control%xtb = .FALSE.
qs_control%semi_empirical = .FALSE.
qs_control%ofgpw = .FALSE.
qs_control%lrigpw = .FALSE.
qs_control%rigpw = .FALSE.
SELECT CASE (qs_control%method_id)
CASE (do_method_gapw)
CALL cite_reference(Lippert1999)
CALL cite_reference(Krack2000)
qs_control%gapw = .TRUE.
CASE (do_method_gapw_xc)
qs_control%gapw_xc = .TRUE.
CASE (do_method_gpw)
CALL cite_reference(Lippert1997)
CALL cite_reference(VandeVondele2005a)
qs_control%gpw = .TRUE.
CASE (do_method_ofgpw)
qs_control%ofgpw = .TRUE.
CASE (do_method_lrigpw)
qs_control%lrigpw = .TRUE.
CASE (do_method_rigpw)
qs_control%rigpw = .TRUE.
CASE (do_method_dftb)
qs_control%dftb = .TRUE.
CALL cite_reference(Porezag1995)
CALL cite_reference(Seifert1996)
CASE (do_method_xtb)
qs_control%xtb = .TRUE.
CALL cite_reference(Grimme2017)
CALL cite_reference(Pracht2019)
CASE (do_method_mndo)
CALL cite_reference(Dewar1977)
qs_control%semi_empirical = .TRUE.
CASE (do_method_am1)
CALL cite_reference(Dewar1985)
qs_control%semi_empirical = .TRUE.
CASE (do_method_pm3)
CALL cite_reference(Stewart1989)
qs_control%semi_empirical = .TRUE.
CASE (do_method_pnnl)
CALL cite_reference(Schenter2008)
qs_control%semi_empirical = .TRUE.
CASE (do_method_pm6)
CALL cite_reference(Stewart2007)
qs_control%semi_empirical = .TRUE.
CASE (do_method_pm6fm)
CALL cite_reference(VanVoorhis2015)
qs_control%semi_empirical = .TRUE.
CASE (do_method_pdg)
CALL cite_reference(Repasky2002)
qs_control%semi_empirical = .TRUE.
CASE (do_method_rm1)
CALL cite_reference(Rocha2006)
qs_control%semi_empirical = .TRUE.
CASE (do_method_mndod)
CALL cite_reference(Dewar1977)
CALL cite_reference(Thiel1992)
qs_control%semi_empirical = .TRUE.
END SELECT
CALL section_vals_get(mull_section, explicit=qs_control%mulliken_restraint)
IF (qs_control%mulliken_restraint) THEN
CALL section_vals_val_get(mull_section, "STRENGTH", r_val=qs_control%mulliken_restraint_control%strength)
CALL section_vals_val_get(mull_section, "TARGET", r_val=qs_control%mulliken_restraint_control%target)
CALL section_vals_val_get(mull_section, "ATOMS", n_rep_val=n_rep)
jj = 0
DO k = 1, n_rep
CALL section_vals_val_get(mull_section, "ATOMS", i_rep_val=k, i_vals=tmplist)
jj = jj + SIZE(tmplist)
END DO
qs_control%mulliken_restraint_control%natoms = jj
IF (qs_control%mulliken_restraint_control%natoms < 1) &
CPABORT("Need at least 1 atom to use mulliken constraints")
ALLOCATE (qs_control%mulliken_restraint_control%atoms(qs_control%mulliken_restraint_control%natoms))
jj = 0
DO k = 1, n_rep
CALL section_vals_val_get(mull_section, "ATOMS", i_rep_val=k, i_vals=tmplist)
DO j = 1, SIZE(tmplist)
jj = jj + 1
qs_control%mulliken_restraint_control%atoms(jj) = tmplist(j)
END DO
END DO
END IF
CALL section_vals_get(ddapc_restraint_section, n_repetition=nrep, explicit=qs_control%ddapc_restraint)
IF (qs_control%ddapc_restraint) THEN
ALLOCATE (qs_control%ddapc_restraint_control(nrep))
CALL read_ddapc_section(qs_control, qs_section=qs_section)
qs_control%ddapc_restraint_is_spin = .FALSE.
qs_control%ddapc_explicit_potential = .FALSE.
END IF
CALL section_vals_get(s2_restraint_section, explicit=qs_control%s2_restraint)