-
Notifications
You must be signed in to change notification settings - Fork 1
/
qs_linres_types.F
1314 lines (1163 loc) · 67.8 KB
/
qs_linres_types.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 Type definitiona for linear response calculations
!> \author MI
! **************************************************************************************************
MODULE qs_linres_types
USE atomic_kind_types, ONLY: atomic_kind_type,&
get_atomic_kind,&
get_atomic_kind_set
USE basis_set_types, ONLY: get_gto_basis_set,&
gto_basis_set_type
USE cp_array_utils, ONLY: cp_2d_i_p_type,&
cp_2d_r_p_type
USE cp_dbcsr_api, ONLY: dbcsr_p_type
USE cp_fm_struct, ONLY: cp_fm_struct_p_type,&
cp_fm_struct_type
USE cp_fm_types, ONLY: cp_fm_release,&
cp_fm_type
USE kinds, ONLY: dp
USE qs_grid_atom, ONLY: grid_atom_type
USE qs_harmonics_atom, ONLY: harmonics_atom_type
USE qs_kind_types, ONLY: get_qs_kind,&
qs_kind_type
USE qs_loc_types, ONLY: qs_loc_env_release,&
qs_loc_env_type
USE qs_rho_atom_types, ONLY: rho_atom_coeff,&
rho_atom_type
USE qs_rho_types, ONLY: qs_rho_p_type,&
qs_rho_release
USE realspace_grid_types, ONLY: realspace_grid_type
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
! **************************************************************************************************
!> \brief General settings for linear response calculations
!> \param property which quantity is to be calculated by LR
!> \param opt_method method to optimize the psi1 by minimization of the second order term of the energy
!> \param preconditioner which kind of preconditioner should be used, if any
!> \param localized_psi 0 : don't use the canonical psi0, but the maximally localized wavefunctions
!> \param do_kernel the kernel is zero if the rho1 is zero as for the magnetic field perturbation
!> \param tolerance convergence criterion for the optimization of the psi1
!> \author MI
! **************************************************************************************************
TYPE linres_control_type
INTEGER :: property = HUGE(0)
INTEGER :: preconditioner_type = HUGE(0)
INTEGER :: restart_every = HUGE(0)
REAL(KIND=dp) :: energy_gap = HUGE(0.0_dp)
INTEGER :: max_iter = HUGE(0)
LOGICAL :: localized_psi0 = .FALSE.
LOGICAL :: do_kernel = .FALSE.
LOGICAL :: converged = .FALSE.
LOGICAL :: linres_restart = .FALSE.
LOGICAL :: lr_triplet = .FALSE.
REAL(KIND=dp) :: eps = HUGE(0.0_dp)
REAL(KIND=dp) :: eps_filter = TINY(0.0_dp)
TYPE(qs_loc_env_type), POINTER :: qs_loc_env => NULL()
CHARACTER(LEN=8) :: flag = ""
END TYPE linres_control_type
! **************************************************************************************************
!> \param ref_coun t
!> \param full_nmr true if the full correction is calculated
!> \param simplenmr_done , fullnmr_done : flags that indicate what has been
!> already calculated: used for restart
!> \param centers_set centers of the maximally localized psi0
!> \param spreads_set spreads of the maximally localized psi0
!> \param p_psi 0 : full matrixes, operator p applied to psi0
!> \param rxp_psi 0 : full matrixes, operator (r-d)xp applied to psi0
!> \param psi 1_p : response wavefunctions to the perturbation given by
!> H1=p (xyz) applied to psi0
!> \param psi 1_rxp : response wavefunctions to the perturbation given by
!> H1=(r-d_i)xp applied to psi0_i where d_i is the center
!> \param psi 1_D : response wavefunctions to the perturbation given by
!> H1=(d_j-d_i)xp applied to psi0_i where d_i is the center
!> and d_j is the center of psi0_j and psi1_D_j is the result
!> This operator has to be used in nstate scf calculations,
!> one for each psi1_D_j vector
!> \param chemical_shift the tensor for each atom
!> \param chi_tensor the susceptibility tensor
!> \param jrho 1_set : current density on the global grid, if gapw this is only the soft part
!> \param jrho 1_atom_set : current density on the local atomic grids (only if gapw)
!> \author MI
! **************************************************************************************************
TYPE current_env_type
LOGICAL :: full = .FALSE.
LOGICAL :: simple_done(6) = .FALSE.
LOGICAL :: simple_converged(6) = .FALSE.
LOGICAL :: do_qmmm = .FALSE.
LOGICAL :: use_old_gauge_atom = .TRUE.
LOGICAL :: chi_pbc = .FALSE.
LOGICAL :: do_selected_states = .FALSE.
LOGICAL :: gauge_init = .FALSE.
LOGICAL :: all_pert_op_done = .FALSE.
LOGICAL, DIMENSION(:, :), POINTER :: full_done => NULL()
INTEGER :: nao = HUGE(1)
INTEGER, DIMENSION(2) :: nstates = HUGE(1)
INTEGER :: gauge = HUGE(1)
INTEGER :: orb_center = HUGE(1)
INTEGER, DIMENSION(2) :: nbr_center = HUGE(1)
INTEGER, DIMENSION(:), POINTER :: list_cubes => NULL()
INTEGER, DIMENSION(:), POINTER :: selected_states_on_atom_list => NULL()
INTEGER, DIMENSION(:, :, :), POINTER :: statetrueindex => NULL()
CHARACTER(LEN=30) :: gauge_name = ""
CHARACTER(LEN=30) :: orb_center_name = ""
REAL(dp) :: chi_tensor(3, 3, 2) = 0.0_dp
REAL(dp) :: chi_tensor_loc(3, 3, 2) = 0.0_dp
REAL(dp) :: gauge_atom_radius = 0.0_dp
REAL(dp) :: selected_states_atom_radius = 0.0_dp
REAL(dp), DIMENSION(:, :), POINTER :: basisfun_center => NULL()
TYPE(cp_2d_i_p_type), DIMENSION(:), POINTER :: center_list => NULL()
TYPE(cp_2d_r_p_type), DIMENSION(:), POINTER :: centers_set => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_p => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_rxp => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_D => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: p_psi0 => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: rxp_psi0 => NULL()
TYPE(jrho_atom_type), DIMENSION(:), POINTER :: jrho1_atom_set => NULL()
TYPE(qs_rho_p_type), DIMENSION(:), POINTER :: jrho1_set => NULL()
TYPE(realspace_grid_type), DIMENSION(:), POINTER :: rs_buf => NULL()
TYPE(realspace_grid_type), DIMENSION(:, :), POINTER :: rs_gauge => NULL()
TYPE(cp_fm_type), DIMENSION(:), POINTER :: psi0_order => NULL()
END TYPE current_env_type
! **************************************************************************************************
! \param type for polarisability calculation using Berry operator
TYPE polar_env_type
LOGICAL :: do_raman = .FALSE.
LOGICAL :: run_stopped = .FALSE.
LOGICAL :: do_periodic = .TRUE.
REAL(dp), DIMENSION(:, :), POINTER :: polar => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_dBerry => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: dBerry_psi0 => NULL()
END TYPE polar_env_type
! **************************************************************************************************
TYPE issc_env_type
INTEGER :: issc_natms = 0
INTEGER, DIMENSION(:), POINTER :: issc_on_atom_list => NULL()
LOGICAL :: interpolate_issc = .FALSE.
LOGICAL :: do_fc = .FALSE.
LOGICAL :: do_sd = .FALSE.
LOGICAL :: do_pso = .FALSE.
LOGICAL :: do_dso = .FALSE.
REAL(dp) :: issc_gapw_radius = 0.0_dp
REAL(dp) :: issc_factor = 0.0_dp
REAL(dp) :: issc_factor_gapw = 0.0_dp
REAL(dp), DIMENSION(:, :, :, :, :), POINTER :: issc => NULL()
REAL(dp), DIMENSION(:, :, :, :, :), POINTER :: issc_loc => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_efg => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_pso => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: psi1_dso => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: efg_psi0 => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: pso_psi0 => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: dso_psi0 => NULL()
TYPE(cp_fm_type), DIMENSION(:), POINTER :: psi1_fc => NULL()
TYPE(cp_fm_type), DIMENSION(:), POINTER :: fc_psi0 => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_efg => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_pso => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_dso => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_fc => NULL()
END TYPE issc_env_type
! **************************************************************************************************
TYPE nmr_env_type
INTEGER :: n_nics = -1
INTEGER, DIMENSION(:), POINTER :: cs_atom_list => NULL()
INTEGER, DIMENSION(:), POINTER :: do_calc_cs_atom => NULL()
LOGICAL :: do_nics = .FALSE.
LOGICAL :: interpolate_shift = .FALSE.
REAL(dp) :: shift_gapw_radius = 0.0_dp
REAL(dp) :: shift_factor = 0.0_dp
REAL(dp) :: shift_factor_gapw = 0.0_dp
REAL(dp) :: chi_factor = 0.0_dp
REAL(dp) :: chi_SI2shiftppm = 0.0_dp
REAL(dp) :: chi_SI2ppmcgs = 0.0_dp
REAL(dp), DIMENSION(:, :), POINTER :: r_nics => NULL()
REAL(dp), DIMENSION(:, :, :), POINTER :: chemical_shift => NULL()
REAL(dp), DIMENSION(:, :, :), POINTER :: chemical_shift_loc => NULL()
REAL(dp), DIMENSION(:, :, :), POINTER :: chemical_shift_nics_loc => NULL()
REAL(dp), DIMENSION(:, :, :), POINTER :: chemical_shift_nics => NULL()
END TYPE nmr_env_type
! **************************************************************************************************
TYPE epr_env_type
REAL(dp) :: g_free_factor = 0.0_dp
REAL(dp) :: g_soo_chicorr_factor = 0.0_dp
REAL(dp) :: g_soo_factor = 0.0_dp
REAL(dp) :: g_so_factor = 0.0_dp
REAL(dp) :: g_so_factor_gapw = 0.0_dp
REAL(dp) :: g_zke_factor = 0.0_dp
REAL(dp) :: g_zke = 0.0_dp
REAL(dp), DIMENSION(:, :), POINTER :: g_total => NULL()
REAL(dp), DIMENSION(:, :), POINTER :: g_so => NULL()
REAL(dp), DIMENSION(:, :), POINTER :: g_soo => NULL()
TYPE(qs_rho_p_type), DIMENSION(:, :), POINTER :: nablavks_set => NULL()
TYPE(nablavks_atom_type), DIMENSION(:), POINTER :: nablavks_atom_set => NULL()
TYPE(qs_rho_p_type), DIMENSION(:, :), POINTER :: bind_set => NULL()
TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: bind_atom_set => NULL()
TYPE(rho_atom_type), DIMENSION(:), POINTER :: vks_atom_set => NULL()
END TYPE epr_env_type
! **************************************************************************************************
TYPE nablavks_atom_type
TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: nablavks_vec_rad_h => NULL()
TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: nablavks_vec_rad_s => NULL()
END TYPE nablavks_atom_type
! **************************************************************************************************
TYPE jrho_atom_type
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_h => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_s => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc0_h => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc0_s => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_ii_h => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_ii_s => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_iii_h => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: cjc_iii_s => NULL()
TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: jrho_vec_rad_h => NULL()
TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: jrho_vec_rad_s => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_h => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_s => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_h => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_s => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_h => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_s => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_h_ii => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_s_ii => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_h_ii => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_s_ii => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_h_iii => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_a_s_iii => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_h_iii => NULL()
TYPE(rho_atom_coeff), DIMENSION(:), POINTER :: jrho_b_s_iii => NULL()
END TYPE jrho_atom_type
! \param type for dC/dR calculation
TYPE dcdr_env_type
INTEGER :: nao = -1
INTEGER :: orb_center = -1
INTEGER :: beta = -1
INTEGER :: lambda = -1
INTEGER :: output_unit = -1
INTEGER :: nspins = -1
INTEGER, DIMENSION(:), ALLOCATABLE :: nmo
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_hc => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s1 => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_t1 => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_t => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ppnl_1 => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_core_charge_1 => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_nosym_temp => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_nosym_temp2 => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: moments => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_apply_op_constant => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: hamiltonian1 => NULL()
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: perturbed_dm_correction => NULL()
TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_vhxc_perturbed_basis => NULL()
TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_difdip => NULL()
TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_d_vhxc_dR => NULL()
REAL(dp), DIMENSION(:, :), POINTER :: deltaR => NULL()
REAL(dp), DIMENSION(:, :), POINTER :: delta_basis_function => NULL()
REAL(dp), DIMENSION(:, :, :, :), POINTER :: apt_subset => NULL()
REAL(dp), DIMENSION(:, :, :, :), POINTER :: apt_at_dcdr_per_center => NULL()
TYPE(cp_fm_type), DIMENSION(:), POINTER :: mo_coeff => NULL()
TYPE(cp_fm_type), DIMENSION(:), POINTER :: dCR => NULL()
TYPE(cp_fm_type), DIMENSION(:), POINTER :: dCR_prime => NULL()
TYPE(cp_fm_type), DIMENSION(:), POINTER :: op_dR => NULL()
TYPE(cp_fm_type), DIMENSION(:), POINTER :: chc => NULL()
TYPE(cp_fm_type), DIMENSION(:), POINTER :: ch1c => NULL()
TYPE(cp_fm_type), DIMENSION(:, :), POINTER :: matrix_m_alpha => NULL()
CHARACTER(LEN=30) :: orb_center_name = ""
TYPE(cp_2d_i_p_type), DIMENSION(:), POINTER :: center_list => NULL()
TYPE(cp_2d_r_p_type), DIMENSION(:), POINTER :: centers_set => NULL()
INTEGER, DIMENSION(2) :: nbr_center = -1
INTEGER, DIMENSION(2) :: nstates = -1
REAL(dp), DIMENSION(3) :: ref_point = 0.0_dp
REAL(dp), DIMENSION(3) :: dipole_pos = 0.0_dp
LOGICAL :: localized_psi0 = .FALSE.
INTEGER, POINTER :: list_of_atoms(:) => NULL()
LOGICAL :: distributed_origin = .FALSE.
LOGICAL :: z_matrix_method = .FALSE.
TYPE(cp_fm_struct_type), POINTER :: aoao_fm_struct => NULL()
TYPE(cp_fm_struct_type), POINTER :: homohomo_fm_struct => NULL()
TYPE(cp_fm_struct_p_type), DIMENSION(:), POINTER :: momo_fm_struct => NULL()
TYPE(cp_fm_struct_p_type), DIMENSION(:), POINTER :: likemos_fm_struct => NULL()
REAL(dp), DIMENSION(:, :, :), POINTER :: apt_el_dcdr => NULL()
REAL(dp), DIMENSION(:, :, :), POINTER :: apt_nuc_dcdr => NULL()
REAL(dp), DIMENSION(:, :, :), POINTER :: apt_total_dcdr => NULL()
REAL(dp), DIMENSION(:, :, :, :), POINTER :: apt_el_dcdr_per_center => NULL()
REAL(dp), DIMENSION(:, :, :, :), POINTER :: apt_el_dcdr_per_subset => NULL()
END TYPE dcdr_env_type
! \param type for VCD calculation
TYPE vcd_env_type
TYPE(dcdr_env_type) :: dcdr_env = dcdr_env_type()
INTEGER :: output_unit = -1
REAL(dp), DIMENSION(3) :: spatial_origin = 0.0_dp
REAL(dp), DIMENSION(3) :: spatial_origin_atom = 0.0_dp
REAL(dp), DIMENSION(3) :: magnetic_origin = 0.0_dp
REAL(dp), DIMENSION(3) :: magnetic_origin_atom = 0.0_dp
LOGICAL :: distributed_origin = .FALSE.
LOGICAL :: origin_dependent_op_mfp = .FALSE.
LOGICAL :: do_mfp = .FALSE.
! APTs and AATs in velocity form
REAL(dp), DIMENSION(:, :, :), POINTER :: apt_el_nvpt => NULL()
REAL(dp), DIMENSION(:, :, :), POINTER :: apt_nuc_nvpt => NULL()
REAL(dp), DIMENSION(:, :, :), POINTER :: apt_total_nvpt => NULL()
REAL(dp), DIMENSION(:, :, :), POINTER :: aat_atom_nvpt => NULL()
REAL(dp), DIMENSION(:, :, :), POINTER :: aat_atom_mfp => NULL()
! Matrices
TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_dSdV => NULL(), &
matrix_drpnl => NULL(), &
matrix_hxc_dsdv => NULL(), &
hcom => NULL(), &
dipvel_ao => NULL(), &
dipvel_ao_delta => NULL(), &
matrix_rxrv => NULL(), &
matrix_dSdB => NULL()
TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_hr => NULL(), &
matrix_rh => NULL(), &
matrix_difdip2 => NULL(), &
moments_der => NULL(), &
moments_der_right => NULL(), &
moments_der_left => NULL(), &
matrix_r_doublecom => NULL(), &
matrix_rcomr => NULL(), &
matrix_rrcom => NULL(), &
matrix_dcom => NULL(), &
matrix_r_rxvr => NULL(), &
matrix_rxvr_r => NULL(), &
matrix_nosym_temp_33 => NULL(), &
matrix_nosym_temp2_33 => NULL()
TYPE(cp_fm_type), DIMENSION(:), POINTER :: dCV => NULL(), &
dCV_prime => NULL(), &
op_dV => NULL(), &
dCB => NULL(), &
dCB_prime => NULL(), &
op_dB => NULL()
END TYPE vcd_env_type
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_linres_types'
! *** Public data types ***
PUBLIC :: linres_control_type, &
nmr_env_type, issc_env_type, jrho_atom_type, &
epr_env_type, dcdr_env_type, vcd_env_type, &
nablavks_atom_type, current_env_type, &
polar_env_type
! *** Public subroutines ***
PUBLIC :: allocate_jrho_atom_rad, deallocate_jrho_atom_set, get_nmr_env, &
get_current_env, allocate_jrho_coeff, init_jrho_atom_set, init_nablavks_atom_set, &
linres_control_release, set_epr_env, deallocate_nablavks_atom_set, &
set2zero_jrho_atom_rad, get_epr_env, get_issc_env, set_current_env, &
get_polar_env, polar_env_release, set_polar_env
CONTAINS
! **************************************************************************************************
!> \brief ...
!> \param linres_control ...
! **************************************************************************************************
SUBROUTINE linres_control_release(linres_control)
TYPE(linres_control_type), INTENT(INOUT) :: linres_control
IF (ASSOCIATED(linres_control%qs_loc_env)) THEN
CALL qs_loc_env_release(linres_control%qs_loc_env)
DEALLOCATE (linres_control%qs_loc_env)
END IF
END SUBROUTINE linres_control_release
! **************************************************************************************************
!> \brief ...
!> \param current_env ...
!> \param simple_done ...
!> \param simple_converged ...
!> \param full_done ...
!> \param nao ...
!> \param nstates ...
!> \param gauge ...
!> \param list_cubes ...
!> \param statetrueindex ...
!> \param gauge_name ...
!> \param basisfun_center ...
!> \param nbr_center ...
!> \param center_list ...
!> \param centers_set ...
!> \param psi1_p ...
!> \param psi1_rxp ...
!> \param psi1_D ...
!> \param p_psi0 ...
!> \param rxp_psi0 ...
!> \param jrho1_atom_set ...
!> \param jrho1_set ...
!> \param chi_tensor ...
!> \param chi_tensor_loc ...
!> \param gauge_atom_radius ...
!> \param rs_gauge ...
!> \param use_old_gauge_atom ...
!> \param chi_pbc ...
!> \param psi0_order ...
! **************************************************************************************************
SUBROUTINE get_current_env(current_env, simple_done, simple_converged, full_done, nao, &
nstates, gauge, list_cubes, statetrueindex, gauge_name, basisfun_center, &
nbr_center, center_list, centers_set, psi1_p, psi1_rxp, psi1_D, p_psi0, &
rxp_psi0, jrho1_atom_set, jrho1_set, chi_tensor, &
chi_tensor_loc, gauge_atom_radius, rs_gauge, use_old_gauge_atom, &
chi_pbc, psi0_order)
TYPE(current_env_type), OPTIONAL :: current_env
LOGICAL, OPTIONAL :: simple_done(6), simple_converged(6)
LOGICAL, DIMENSION(:, :), OPTIONAL, POINTER :: full_done
INTEGER, OPTIONAL :: nao, nstates(2), gauge
INTEGER, DIMENSION(:), OPTIONAL, POINTER :: list_cubes
INTEGER, DIMENSION(:, :, :), OPTIONAL, POINTER :: statetrueindex
CHARACTER(LEN=30), OPTIONAL :: gauge_name
REAL(dp), DIMENSION(:, :), OPTIONAL, POINTER :: basisfun_center
INTEGER, OPTIONAL :: nbr_center(2)
TYPE(cp_2d_i_p_type), DIMENSION(:), OPTIONAL, &
POINTER :: center_list
TYPE(cp_2d_r_p_type), DIMENSION(:), OPTIONAL, &
POINTER :: centers_set
TYPE(cp_fm_type), DIMENSION(:, :), OPTIONAL, &
POINTER :: psi1_p, psi1_rxp, psi1_D, p_psi0, &
rxp_psi0
TYPE(jrho_atom_type), DIMENSION(:), OPTIONAL, &
POINTER :: jrho1_atom_set
TYPE(qs_rho_p_type), DIMENSION(:), OPTIONAL, &
POINTER :: jrho1_set
REAL(dp), INTENT(OUT), OPTIONAL :: chi_tensor(3, 3, 2), &
chi_tensor_loc(3, 3, 2), &
gauge_atom_radius
TYPE(realspace_grid_type), DIMENSION(:, :), &
OPTIONAL, POINTER :: rs_gauge
LOGICAL, OPTIONAL :: use_old_gauge_atom, chi_pbc
TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: psi0_order
IF (PRESENT(simple_done)) simple_done(1:6) = current_env%simple_done(1:6)
IF (PRESENT(simple_converged)) simple_converged(1:6) = current_env%simple_converged(1:6)
IF (PRESENT(full_done)) full_done => current_env%full_done
IF (PRESENT(nao)) nao = current_env%nao
IF (PRESENT(nstates)) nstates(1:2) = current_env%nstates(1:2)
IF (PRESENT(gauge)) gauge = current_env%gauge
IF (PRESENT(list_cubes)) list_cubes => current_env%list_cubes
IF (PRESENT(statetrueindex)) statetrueindex => current_env%statetrueindex
IF (PRESENT(gauge_name)) gauge_name = current_env%gauge_name
IF (PRESENT(basisfun_center)) basisfun_center => current_env%basisfun_center
IF (PRESENT(nbr_center)) nbr_center(1:2) = current_env%nbr_center(1:2)
IF (PRESENT(center_list)) center_list => current_env%center_list
IF (PRESENT(centers_set)) centers_set => current_env%centers_set
IF (PRESENT(chi_tensor)) chi_tensor(:, :, :) = current_env%chi_tensor(:, :, :)
IF (PRESENT(chi_tensor_loc)) chi_tensor_loc(:, :, :) = current_env%chi_tensor_loc(:, :, :)
IF (PRESENT(psi1_p)) psi1_p => current_env%psi1_p
IF (PRESENT(psi1_rxp)) psi1_rxp => current_env%psi1_rxp
IF (PRESENT(psi1_D)) psi1_D => current_env%psi1_D
IF (PRESENT(p_psi0)) p_psi0 => current_env%p_psi0
IF (PRESENT(rxp_psi0)) rxp_psi0 => current_env%rxp_psi0
IF (PRESENT(jrho1_atom_set)) jrho1_atom_set => current_env%jrho1_atom_set
IF (PRESENT(jrho1_set)) jrho1_set => current_env%jrho1_set
IF (PRESENT(rs_gauge)) rs_gauge => current_env%rs_gauge
IF (PRESENT(psi0_order)) psi0_order => current_env%psi0_order
IF (PRESENT(chi_pbc)) chi_pbc = current_env%chi_pbc
IF (PRESENT(gauge_atom_radius)) gauge_atom_radius = current_env%gauge_atom_radius
IF (PRESENT(use_old_gauge_atom)) use_old_gauge_atom = current_env%use_old_gauge_atom
END SUBROUTINE get_current_env
! **************************************************************************************************
!> \brief ...
!> \param nmr_env ...
!> \param n_nics ...
!> \param cs_atom_list ...
!> \param do_calc_cs_atom ...
!> \param r_nics ...
!> \param chemical_shift ...
!> \param chemical_shift_loc ...
!> \param chemical_shift_nics_loc ...
!> \param chemical_shift_nics ...
!> \param shift_gapw_radius ...
!> \param do_nics ...
!> \param interpolate_shift ...
! **************************************************************************************************
SUBROUTINE get_nmr_env(nmr_env, n_nics, cs_atom_list, do_calc_cs_atom, &
r_nics, chemical_shift, chemical_shift_loc, &
chemical_shift_nics_loc, chemical_shift_nics, &
shift_gapw_radius, do_nics, interpolate_shift)
TYPE(nmr_env_type) :: nmr_env
INTEGER, INTENT(OUT), OPTIONAL :: n_nics
INTEGER, DIMENSION(:), OPTIONAL, POINTER :: cs_atom_list, do_calc_cs_atom
REAL(dp), DIMENSION(:, :), OPTIONAL, POINTER :: r_nics
REAL(dp), DIMENSION(:, :, :), OPTIONAL, POINTER :: chemical_shift, chemical_shift_loc, &
chemical_shift_nics_loc, &
chemical_shift_nics
REAL(dp), INTENT(OUT), OPTIONAL :: shift_gapw_radius
LOGICAL, INTENT(OUT), OPTIONAL :: do_nics, interpolate_shift
IF (PRESENT(n_nics)) n_nics = nmr_env%n_nics
IF (PRESENT(cs_atom_list)) cs_atom_list => nmr_env%cs_atom_list
IF (PRESENT(do_calc_cs_atom)) do_calc_cs_atom => nmr_env%do_calc_cs_atom
IF (PRESENT(chemical_shift)) chemical_shift => nmr_env%chemical_shift
IF (PRESENT(chemical_shift_loc)) chemical_shift_loc => nmr_env%chemical_shift_loc
IF (PRESENT(chemical_shift_nics)) chemical_shift_nics => nmr_env%chemical_shift_nics
IF (PRESENT(r_nics)) r_nics => nmr_env%r_nics
IF (PRESENT(chemical_shift_nics_loc)) chemical_shift_nics_loc => nmr_env%chemical_shift_nics_loc
IF (PRESENT(shift_gapw_radius)) shift_gapw_radius = nmr_env%shift_gapw_radius
IF (PRESENT(do_nics)) do_nics = nmr_env%do_nics
IF (PRESENT(interpolate_shift)) interpolate_shift = nmr_env%interpolate_shift
END SUBROUTINE get_nmr_env
! **************************************************************************************************
!> \brief ...
!> \param issc_env ...
!> \param issc_on_atom_list ...
!> \param issc_gapw_radius ...
!> \param issc_loc ...
!> \param do_fc ...
!> \param do_sd ...
!> \param do_pso ...
!> \param do_dso ...
!> \param issc ...
!> \param interpolate_issc ...
!> \param psi1_efg ...
!> \param psi1_pso ...
!> \param psi1_dso ...
!> \param psi1_fc ...
!> \param efg_psi0 ...
!> \param pso_psi0 ...
!> \param dso_psi0 ...
!> \param fc_psi0 ...
!> \param matrix_efg ...
!> \param matrix_pso ...
!> \param matrix_dso ...
!> \param matrix_fc ...
! **************************************************************************************************
SUBROUTINE get_issc_env(issc_env, issc_on_atom_list, issc_gapw_radius, issc_loc, &
do_fc, do_sd, do_pso, do_dso, &
issc, interpolate_issc, psi1_efg, psi1_pso, psi1_dso, psi1_fc, efg_psi0, pso_psi0, dso_psi0, fc_psi0, &
matrix_efg, matrix_pso, matrix_dso, matrix_fc)
TYPE(issc_env_type) :: issc_env
INTEGER, DIMENSION(:), OPTIONAL, POINTER :: issc_on_atom_list
REAL(dp), OPTIONAL :: issc_gapw_radius
REAL(dp), DIMENSION(:, :, :, :, :), OPTIONAL, &
POINTER :: issc_loc
LOGICAL, OPTIONAL :: do_fc, do_sd, do_pso, do_dso
REAL(dp), DIMENSION(:, :, :, :, :), OPTIONAL, &
POINTER :: issc
LOGICAL, OPTIONAL :: interpolate_issc
TYPE(cp_fm_type), DIMENSION(:, :), OPTIONAL, &
POINTER :: psi1_efg, psi1_pso, psi1_dso
TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: psi1_fc
TYPE(cp_fm_type), DIMENSION(:, :), OPTIONAL, &
POINTER :: efg_psi0, pso_psi0, dso_psi0
TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: fc_psi0
TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
POINTER :: matrix_efg, matrix_pso, matrix_dso, &
matrix_fc
IF (PRESENT(issc_on_atom_list)) issc_on_atom_list => issc_env%issc_on_atom_list
IF (PRESENT(issc_gapw_radius)) issc_gapw_radius = issc_env%issc_gapw_radius
IF (PRESENT(issc_loc)) issc_loc => issc_env%issc_loc
IF (PRESENT(issc)) issc => issc_env%issc
IF (PRESENT(interpolate_issc)) interpolate_issc = issc_env%interpolate_issc
IF (PRESENT(psi1_efg)) psi1_efg => issc_env%psi1_efg
IF (PRESENT(psi1_pso)) psi1_pso => issc_env%psi1_pso
IF (PRESENT(psi1_dso)) psi1_dso => issc_env%psi1_dso
IF (PRESENT(psi1_fc)) psi1_fc => issc_env%psi1_fc
IF (PRESENT(efg_psi0)) efg_psi0 => issc_env%efg_psi0
IF (PRESENT(pso_psi0)) pso_psi0 => issc_env%pso_psi0
IF (PRESENT(dso_psi0)) dso_psi0 => issc_env%dso_psi0
IF (PRESENT(fc_psi0)) fc_psi0 => issc_env%fc_psi0
IF (PRESENT(matrix_efg)) matrix_efg => issc_env%matrix_efg
IF (PRESENT(matrix_pso)) matrix_pso => issc_env%matrix_pso
IF (PRESENT(matrix_fc)) matrix_fc => issc_env%matrix_fc
IF (PRESENT(matrix_dso)) matrix_dso => issc_env%matrix_dso
IF (PRESENT(do_fc)) do_fc = issc_env%do_fc
IF (PRESENT(do_sd)) do_sd = issc_env%do_sd
IF (PRESENT(do_pso)) do_pso = issc_env%do_pso
IF (PRESENT(do_dso)) do_dso = issc_env%do_dso
END SUBROUTINE get_issc_env
! **************************************************************************************************
!> \brief ...
!> \param current_env ...
!> \param jrho1_atom_set ...
!> \param jrho1_set ...
! **************************************************************************************************
SUBROUTINE set_current_env(current_env, jrho1_atom_set, jrho1_set)
TYPE(current_env_type) :: current_env
TYPE(jrho_atom_type), DIMENSION(:), OPTIONAL, &
POINTER :: jrho1_atom_set
TYPE(qs_rho_p_type), DIMENSION(:), OPTIONAL, &
POINTER :: jrho1_set
INTEGER :: idir
IF (PRESENT(jrho1_atom_set)) THEN
IF (ASSOCIATED(current_env%jrho1_atom_set)) THEN
CALL deallocate_jrho_atom_set(current_env%jrho1_atom_set)
END IF
current_env%jrho1_atom_set => jrho1_atom_set
END IF
IF (PRESENT(jrho1_set)) THEN
IF (ASSOCIATED(current_env%jrho1_set)) THEN
DO idir = 1, 3
CALL qs_rho_release(current_env%jrho1_set(idir)%rho)
DEALLOCATE (current_env%jrho1_set(idir)%rho)
END DO
END IF
current_env%jrho1_set => jrho1_set
END IF
END SUBROUTINE set_current_env
! **************************************************************************************************
!> \brief ...
!> \param epr_env ...
!> \param g_total ...
!> \param g_so ...
!> \param g_soo ...
!> \param nablavks_set ...
!> \param nablavks_atom_set ...
!> \param bind_set ...
!> \param bind_atom_set ...
! **************************************************************************************************
SUBROUTINE get_epr_env(epr_env, g_total, g_so, g_soo, nablavks_set, nablavks_atom_set, &
bind_set, bind_atom_set)
TYPE(epr_env_type) :: epr_env
REAL(dp), DIMENSION(:, :), OPTIONAL, POINTER :: g_total, g_so, g_soo
TYPE(qs_rho_p_type), DIMENSION(:, :), OPTIONAL, &
POINTER :: nablavks_set
TYPE(nablavks_atom_type), DIMENSION(:), OPTIONAL, &
POINTER :: nablavks_atom_set
TYPE(qs_rho_p_type), DIMENSION(:, :), OPTIONAL, &
POINTER :: bind_set
TYPE(rho_atom_coeff), DIMENSION(:, :), OPTIONAL, &
POINTER :: bind_atom_set
IF (PRESENT(g_total)) g_total => epr_env%g_total
IF (PRESENT(g_so)) g_so => epr_env%g_so
IF (PRESENT(g_soo)) g_soo => epr_env%g_soo
IF (PRESENT(nablavks_set)) nablavks_set => epr_env%nablavks_set
IF (PRESENT(nablavks_atom_set)) nablavks_atom_set => epr_env%nablavks_atom_set
IF (PRESENT(bind_set)) bind_set => epr_env%bind_set
IF (PRESENT(bind_atom_set)) bind_atom_set => epr_env%bind_atom_set
END SUBROUTINE get_epr_env
! **************************************************************************************************
!> \brief ...
!> \param epr_env ...
!> \param g_free_factor ...
!> \param g_soo_chicorr_factor ...
!> \param g_soo_factor ...
!> \param g_so_factor ...
!> \param g_so_factor_gapw ...
!> \param g_zke_factor ...
!> \param nablavks_set ...
!> \param nablavks_atom_set ...
! **************************************************************************************************
SUBROUTINE set_epr_env(epr_env, g_free_factor, g_soo_chicorr_factor, &
g_soo_factor, g_so_factor, g_so_factor_gapw, &
g_zke_factor, nablavks_set, nablavks_atom_set)
TYPE(epr_env_type) :: epr_env
REAL(dp), INTENT(IN), OPTIONAL :: g_free_factor, g_soo_chicorr_factor, &
g_soo_factor, g_so_factor, &
g_so_factor_gapw, g_zke_factor
TYPE(qs_rho_p_type), DIMENSION(:, :), OPTIONAL, &
POINTER :: nablavks_set
TYPE(nablavks_atom_type), DIMENSION(:), OPTIONAL, &
POINTER :: nablavks_atom_set
INTEGER :: idir, ispin
IF (PRESENT(g_free_factor)) epr_env%g_free_factor = g_free_factor
IF (PRESENT(g_zke_factor)) epr_env%g_zke_factor = g_zke_factor
IF (PRESENT(g_so_factor)) epr_env%g_so_factor = g_so_factor
IF (PRESENT(g_so_factor_gapw)) epr_env%g_so_factor_gapw = g_so_factor_gapw
IF (PRESENT(g_soo_factor)) epr_env%g_soo_factor = g_soo_factor
IF (PRESENT(g_soo_chicorr_factor)) epr_env%g_soo_chicorr_factor = g_soo_chicorr_factor
IF (PRESENT(nablavks_set)) THEN
IF (ASSOCIATED(epr_env%nablavks_set)) THEN
DO ispin = 1, 2
DO idir = 1, 3
CALL qs_rho_release(epr_env%nablavks_set(idir, ispin)%rho)
DEALLOCATE (epr_env%nablavks_set(idir, ispin)%rho)
END DO
END DO
END IF
epr_env%nablavks_set => nablavks_set
END IF
IF (PRESENT(nablavks_atom_set)) THEN
IF (ASSOCIATED(epr_env%nablavks_atom_set)) THEN
CALL deallocate_nablavks_atom_set(epr_env%nablavks_atom_set)
END IF
epr_env%nablavks_atom_set => nablavks_atom_set
END IF
END SUBROUTINE set_epr_env
! **************************************************************************************************
!> \brief ...
!> \param nablavks_atom_set ...
!> \param natom ...
! **************************************************************************************************
SUBROUTINE allocate_nablavks_atom_set(nablavks_atom_set, natom)
TYPE(nablavks_atom_type), DIMENSION(:), POINTER :: nablavks_atom_set
INTEGER, INTENT(IN) :: natom
INTEGER :: iat
ALLOCATE (nablavks_atom_set(natom))
DO iat = 1, natom
NULLIFY (nablavks_atom_set(iat)%nablavks_vec_rad_h)
NULLIFY (nablavks_atom_set(iat)%nablavks_vec_rad_s)
END DO
END SUBROUTINE allocate_nablavks_atom_set
! **************************************************************************************************
!> \brief ...
!> \param nablavks_atom_set ...
! **************************************************************************************************
SUBROUTINE deallocate_nablavks_atom_set(nablavks_atom_set)
TYPE(nablavks_atom_type), DIMENSION(:), POINTER :: nablavks_atom_set
INTEGER :: i, iat, idir, n, natom
CPASSERT(ASSOCIATED(nablavks_atom_set))
natom = SIZE(nablavks_atom_set)
DO iat = 1, natom
IF (ASSOCIATED(nablavks_atom_set(iat)%nablavks_vec_rad_h)) THEN
IF (ASSOCIATED(nablavks_atom_set(iat)%nablavks_vec_rad_h(1, 1)%r_coef)) THEN
n = SIZE(nablavks_atom_set(iat)%nablavks_vec_rad_h, 2)
DO i = 1, n
DO idir = 1, 3
DEALLOCATE (nablavks_atom_set(iat)%nablavks_vec_rad_h(idir, i)%r_coef)
DEALLOCATE (nablavks_atom_set(iat)%nablavks_vec_rad_s(idir, i)%r_coef)
END DO
END DO
END IF
DEALLOCATE (nablavks_atom_set(iat)%nablavks_vec_rad_h)
DEALLOCATE (nablavks_atom_set(iat)%nablavks_vec_rad_s)
END IF
END DO
DEALLOCATE (nablavks_atom_set)
END SUBROUTINE deallocate_nablavks_atom_set
! **************************************************************************************************
!> \brief ...
!> \param jrho_atom_set ...
! **************************************************************************************************
SUBROUTINE deallocate_jrho_atom_set(jrho_atom_set)
TYPE(jrho_atom_type), DIMENSION(:), POINTER :: jrho_atom_set
INTEGER :: i, iat, idir, n, natom
CPASSERT(ASSOCIATED(jrho_atom_set))
natom = SIZE(jrho_atom_set)
DO iat = 1, natom
IF (ASSOCIATED(jrho_atom_set(iat)%cjc_h)) THEN
IF (ASSOCIATED(jrho_atom_set(iat)%cjc_h(1)%r_coef)) THEN
n = SIZE(jrho_atom_set(iat)%cjc_h)
DO i = 1, n
!
! size = (nsotot,nsotot) replicated
DEALLOCATE (jrho_atom_set(iat)%cjc0_h(i)%r_coef, &
jrho_atom_set(iat)%cjc0_s(i)%r_coef, &
jrho_atom_set(iat)%cjc_h(i)%r_coef, &
jrho_atom_set(iat)%cjc_s(i)%r_coef, &
jrho_atom_set(iat)%cjc_ii_h(i)%r_coef, &
jrho_atom_set(iat)%cjc_ii_s(i)%r_coef, &
jrho_atom_set(iat)%cjc_iii_h(i)%r_coef, &
jrho_atom_set(iat)%cjc_iii_s(i)%r_coef)
END DO
END IF
DEALLOCATE (jrho_atom_set(iat)%cjc0_h, &
jrho_atom_set(iat)%cjc0_s, &
jrho_atom_set(iat)%cjc_h, &
jrho_atom_set(iat)%cjc_s, &
jrho_atom_set(iat)%cjc_ii_h, &
jrho_atom_set(iat)%cjc_ii_s, &
jrho_atom_set(iat)%cjc_iii_h, &
jrho_atom_set(iat)%cjc_iii_s)
END IF
IF (ASSOCIATED(jrho_atom_set(iat)%jrho_a_h)) THEN
IF (ASSOCIATED(jrho_atom_set(iat)%jrho_a_h(1)%r_coef)) THEN
n = SIZE(jrho_atom_set(iat)%jrho_a_h)
DO i = 1, n
!
! size = (nr,max_iso_not0) distributed
DEALLOCATE (jrho_atom_set(iat)%jrho_h(i)%r_coef, &
jrho_atom_set(iat)%jrho_s(i)%r_coef, &
jrho_atom_set(iat)%jrho_a_h(i)%r_coef, &
jrho_atom_set(iat)%jrho_a_s(i)%r_coef, &
jrho_atom_set(iat)%jrho_b_h(i)%r_coef, &
jrho_atom_set(iat)%jrho_b_s(i)%r_coef, &
jrho_atom_set(iat)%jrho_a_h_ii(i)%r_coef, &
jrho_atom_set(iat)%jrho_a_s_ii(i)%r_coef, &
jrho_atom_set(iat)%jrho_b_h_ii(i)%r_coef, &
jrho_atom_set(iat)%jrho_b_s_ii(i)%r_coef, &
jrho_atom_set(iat)%jrho_a_h_iii(i)%r_coef, &
jrho_atom_set(iat)%jrho_a_s_iii(i)%r_coef, &
jrho_atom_set(iat)%jrho_b_h_iii(i)%r_coef, &
jrho_atom_set(iat)%jrho_b_s_iii(i)%r_coef)
END DO
END IF
DEALLOCATE (jrho_atom_set(iat)%jrho_h, &
jrho_atom_set(iat)%jrho_s, &
jrho_atom_set(iat)%jrho_a_h, &
jrho_atom_set(iat)%jrho_a_s, &
jrho_atom_set(iat)%jrho_b_h, &
jrho_atom_set(iat)%jrho_b_s, &
jrho_atom_set(iat)%jrho_a_h_ii, &
jrho_atom_set(iat)%jrho_a_s_ii, &
jrho_atom_set(iat)%jrho_b_h_ii, &
jrho_atom_set(iat)%jrho_b_s_ii, &
jrho_atom_set(iat)%jrho_a_h_iii, &
jrho_atom_set(iat)%jrho_a_s_iii, &
jrho_atom_set(iat)%jrho_b_h_iii, &
jrho_atom_set(iat)%jrho_b_s_iii)
END IF
IF (ASSOCIATED(jrho_atom_set(iat)%jrho_vec_rad_h)) THEN
IF (ASSOCIATED(jrho_atom_set(iat)%jrho_vec_rad_h(1, 1)%r_coef)) THEN
n = SIZE(jrho_atom_set(iat)%jrho_vec_rad_h, 2)
DO i = 1, n
DO idir = 1, 3
!
! size =(nr,na) distributed
DEALLOCATE (jrho_atom_set(iat)%jrho_vec_rad_h(idir, i)%r_coef, &
jrho_atom_set(iat)%jrho_vec_rad_s(idir, i)%r_coef)
END DO
END DO
END IF
DEALLOCATE (jrho_atom_set(iat)%jrho_vec_rad_h, &
jrho_atom_set(iat)%jrho_vec_rad_s)
END IF
END DO
DEALLOCATE (jrho_atom_set)
END SUBROUTINE deallocate_jrho_atom_set
! **************************************************************************************************
!> \brief ...
!> \param jrho1_atom ...
!> \param ispin ...
!> \param nr ...
!> \param na ...
!> \param max_iso_not0 ...
! **************************************************************************************************
SUBROUTINE allocate_jrho_atom_rad(jrho1_atom, ispin, nr, na, max_iso_not0)
TYPE(jrho_atom_type), POINTER :: jrho1_atom
INTEGER, INTENT(IN) :: ispin, nr, na, max_iso_not0
CHARACTER(len=*), PARAMETER :: routineN = 'allocate_jrho_atom_rad'
INTEGER :: handle, idir
CALL timeset(routineN, handle)
CPASSERT(ASSOCIATED(jrho1_atom))
DO idir = 1, 3
ALLOCATE (jrho1_atom%jrho_vec_rad_h(idir, ispin)%r_coef(nr, na), &
jrho1_atom%jrho_vec_rad_s(idir, ispin)%r_coef(nr, na))
jrho1_atom%jrho_vec_rad_h(idir, ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_vec_rad_s(idir, ispin)%r_coef = 0.0_dp
END DO
ALLOCATE (jrho1_atom%jrho_h(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_s(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_a_h(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_a_s(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_b_h(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_b_s(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_a_h_ii(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_a_s_ii(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_b_h_ii(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_b_s_ii(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_a_h_iii(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_a_s_iii(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_b_h_iii(ispin)%r_coef(nr, max_iso_not0), &
jrho1_atom%jrho_b_s_iii(ispin)%r_coef(nr, max_iso_not0))
!
jrho1_atom%jrho_h(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_s(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_a_h(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_a_s(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_h(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_s(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_a_h_ii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_a_s_ii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_h_ii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_s_ii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_a_h_iii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_a_s_iii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_h_iii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_s_iii(ispin)%r_coef = 0.0_dp
CALL timestop(handle)
END SUBROUTINE allocate_jrho_atom_rad
! **************************************************************************************************
!> \brief ...
!> \param jrho1_atom ...
!> \param ispin ...
! **************************************************************************************************
SUBROUTINE set2zero_jrho_atom_rad(jrho1_atom, ispin)
!
TYPE(jrho_atom_type), POINTER :: jrho1_atom
INTEGER, INTENT(IN) :: ispin
!
CPASSERT(ASSOCIATED(jrho1_atom))
!
jrho1_atom%jrho_h(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_s(ispin)%r_coef = 0.0_dp
!
jrho1_atom%jrho_a_h(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_a_s(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_h(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_s(ispin)%r_coef = 0.0_dp
!
jrho1_atom%jrho_a_h_ii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_a_s_ii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_h_ii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_s_ii(ispin)%r_coef = 0.0_dp
!
jrho1_atom%jrho_a_h_iii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_a_s_iii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_h_iii(ispin)%r_coef = 0.0_dp
jrho1_atom%jrho_b_s_iii(ispin)%r_coef = 0.0_dp
!
END SUBROUTINE set2zero_jrho_atom_rad
! **************************************************************************************************
! **************************************************************************************************
!> \brief ...
!> \param jrho1_atom_set ...
!> \param iatom ...
!> \param nsotot ...
! **************************************************************************************************
SUBROUTINE allocate_jrho_coeff(jrho1_atom_set, iatom, nsotot)
TYPE(jrho_atom_type), DIMENSION(:), POINTER :: jrho1_atom_set
INTEGER, INTENT(IN) :: iatom, nsotot
CHARACTER(len=*), PARAMETER :: routineN = 'allocate_jrho_coeff'
INTEGER :: handle, i
CALL timeset(routineN, handle)
CPASSERT(ASSOCIATED(jrho1_atom_set))
DO i = 1, SIZE(jrho1_atom_set(iatom)%cjc0_h, 1)
ALLOCATE (jrho1_atom_set(iatom)%cjc0_h(i)%r_coef(nsotot, nsotot), &
jrho1_atom_set(iatom)%cjc0_s(i)%r_coef(nsotot, nsotot), &
jrho1_atom_set(iatom)%cjc_h(i)%r_coef(nsotot, nsotot), &
jrho1_atom_set(iatom)%cjc_s(i)%r_coef(nsotot, nsotot), &
jrho1_atom_set(iatom)%cjc_ii_h(i)%r_coef(nsotot, nsotot), &
jrho1_atom_set(iatom)%cjc_ii_s(i)%r_coef(nsotot, nsotot), &
jrho1_atom_set(iatom)%cjc_iii_h(i)%r_coef(nsotot, nsotot), &