-
Notifications
You must be signed in to change notification settings - Fork 1
/
pair_potential_types.F
2722 lines (2466 loc) · 124 KB
/
pair_potential_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 !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \par History
!> Teodoro Laino [Teo] 11.2005 : Reorganizing the structures to optimize
!> memory management
!> \author CJM
! **************************************************************************************************
MODULE pair_potential_types
USE kinds, ONLY: default_path_length,&
default_string_length,&
dp
USE memory_utilities, ONLY: reallocate
USE splines_types, ONLY: spline_data_p_copy,&
spline_data_p_release,&
spline_data_p_type,&
spline_factor_copy,&
spline_factor_release,&
spline_factor_type
#include "./base/base_uses.f90"
IMPLICIT NONE
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'pair_potential_types'
PRIVATE
! when adding a new nonbonded potential please update also the list_pot
! used for the linear scaling screening of potential calculation
INTEGER, PUBLIC, PARAMETER :: multi_type = -1, &
nn_type = 0, &
lj_type = 1, &
lj_charmm_type = 2, &
ft_type = 3, &
wl_type = 4, &
gw_type = 5, &
ip_type = 6, &
ea_type = 7, &
b4_type = 8, &
bm_type = 9, &
gp_type = 10, &
tersoff_type = 11, &
ftd_type = 12, &
siepmann_type = 13, &
gal_type = 14, &
quip_type = 15, &
nequip_type = 16, &
allegro_type = 17, &
gal21_type = 18, &
tab_type = 19, &
deepmd_type = 20
INTEGER, PUBLIC, PARAMETER, DIMENSION(21) :: list_pot = (/nn_type, &
lj_type, &
lj_charmm_type, &
ft_type, &
wl_type, &
gw_type, &
ip_type, &
ea_type, &
b4_type, &
bm_type, &
gp_type, &
tersoff_type, &
ftd_type, &
siepmann_type, &
gal_type, &
quip_type, &
nequip_type, &
allegro_type, &
gal21_type, &
tab_type, &
deepmd_type/)
! Shell model
INTEGER, PUBLIC, PARAMETER :: nosh_nosh = 0, &
nosh_sh = 1, &
sh_sh = 2
INTEGER, PUBLIC, PARAMETER, DIMENSION(3) :: list_sh_type = (/nosh_nosh, nosh_sh, sh_sh/)
! Single Spline generation info
REAL(KIND=dp), PARAMETER, PUBLIC :: not_initialized = -HUGE(0.0_dp)
INTEGER, PARAMETER, DIMENSION(2), PUBLIC :: do_potential_single_allocation = (/lj_type, lj_charmm_type/)
INTEGER, PARAMETER, DIMENSION(2), PUBLIC :: no_potential_single_allocation = (/-HUGE(0), -HUGE(0)/)
INTEGER, DIMENSION(2), PUBLIC :: potential_single_allocation
PUBLIC :: pair_potential_reallocate
PUBLIC :: pair_potential_single_copy, &
pair_potential_single_add, &
pair_potential_single_clean, &
pair_potential_single_type
PUBLIC :: pair_potential_pp_create, &
pair_potential_pp_release, &
pair_potential_pp_type
PUBLIC :: pair_potential_p_type, &
pair_potential_p_release
PUBLIC :: ft_pot_type, &
ipbv_pot_type, &
eam_pot_type, &
quip_pot_type, &
nequip_pot_type, &
allegro_pot_type, &
deepmd_pot_type, &
tersoff_pot_type, &
siepmann_pot_type, &
gal_pot_type, &
gal21_pot_type, &
tab_pot_type
PUBLIC :: pair_potential_lj_create
PUBLIC :: compare_pot
! **************************************************************************************************
TYPE ipbv_pot_type
REAL(KIND=dp), DIMENSION(2:15) :: a = 0.0_dp
REAL(KIND=dp) :: rcore = 0.0_dp
REAL(KIND=dp) :: m = 0.0_dp
REAL(KIND=dp) :: b = 0.0_dp
END TYPE ipbv_pot_type
! **************************************************************************************************
TYPE lj_pot_type
REAL(KIND=dp) :: epsilon = 0.0_dp
REAL(KIND=dp) :: sigma6 = 0.0_dp
REAL(KIND=dp) :: sigma12 = 0.0_dp
END TYPE Lj_pot_type
! **************************************************************************************************
TYPE ft_pot_type
REAL(KIND=dp) :: A = 0.0_dp
REAL(KIND=dp) :: B = 0.0_dp
REAL(KIND=dp) :: C = 0.0_dp
REAL(KIND=dp) :: D = 0.0_dp
END TYPE ft_pot_type
! **************************************************************************************************
TYPE ftd_pot_type
REAL(KIND=dp) :: A = 0.0_dp
REAL(KIND=dp) :: B = 0.0_dp
REAL(KIND=dp) :: C = 0.0_dp
REAL(KIND=dp) :: D = 0.0_dp
REAL(KIND=dp), DIMENSION(2) :: BD = 0.0_dp
END TYPE ftd_pot_type
! **************************************************************************************************
TYPE williams_pot_type
REAL(KIND=dp) :: a = 0.0_dp
REAL(KIND=dp) :: b = 0.0_dp
REAL(KIND=dp) :: c = 0.0_dp
END TYPE williams_pot_type
! **************************************************************************************************
TYPE goodwin_pot_type
REAL(KIND=dp) :: vr0 = 0.0_dp
REAL(KIND=dp) :: m = 0.0_dp, mc = 0.0_dp
REAL(KIND=dp) :: d = 0.0_dp, dc = 0.0_dp
END TYPE goodwin_pot_type
! **************************************************************************************************
TYPE eam_pot_type
CHARACTER(LEN=default_path_length) :: eam_file_name = ""
INTEGER :: npoints = 0
REAL(KIND=dp) :: drar = 0.0_dp, drhoar = 0.0_dp, acutal = 0.0_dp
REAL(KIND=dp), POINTER, DIMENSION(:) :: rho => NULL(), phi => NULL(), frho => NULL(), rhoval => NULL(), rval => NULL()
REAL(KIND=dp), POINTER, DIMENSION(:) :: rhop => NULL(), phip => NULL(), frhop => NULL()
END TYPE eam_pot_type
! **************************************************************************************************
TYPE deepmd_pot_type
CHARACTER(LEN=default_path_length) :: deepmd_file_name = 'NULL'
INTEGER :: atom_deepmd_type = 0
END TYPE deepmd_pot_type
! **************************************************************************************************
TYPE quip_pot_type
CHARACTER(LEN=default_path_length) :: quip_file_name = ""
CHARACTER(LEN=1024) :: init_args = ""
CHARACTER(LEN=1024) :: calc_args = ""
END TYPE quip_pot_type
! **************************************************************************************************
TYPE nequip_pot_type
CHARACTER(LEN=default_path_length) :: nequip_file_name = 'NULL', nequip_version = 'NULL', &
unit_coords = 'NULL', unit_forces = 'NULL', &
unit_energy = 'NULL', unit_cell = 'NULL'
CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE :: type_names_torch
REAL(KIND=dp) :: rcutsq = 0.0_dp, unit_coords_val = 1.0_dp, &
unit_forces_val = 1.0_dp, unit_energy_val = 1.0_dp, &
unit_cell_val = 1.0_dp
LOGICAL :: do_nequip_sp = .FALSE.
END TYPE nequip_pot_type
! **************************************************************************************************
TYPE allegro_pot_type
CHARACTER(LEN=default_path_length) :: allegro_file_name = 'NULL', unit_cell = 'NULL', &
nequip_version = 'NULL', unit_coords = 'NULL', &
unit_forces = 'NULL', unit_energy = 'NULL'
CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE :: type_names_torch
REAL(KIND=dp) :: rcutsq = 0.0_dp, unit_coords_val = 1.0_dp, &
unit_forces_val = 1.0_dp, unit_cell_val = 1.0_dp, &
unit_energy_val = 1.0_dp
LOGICAL :: do_allegro_sp = .FALSE.
END TYPE allegro_pot_type
! **************************************************************************************************
TYPE buck4ran_pot_type
REAL(KIND=dp) :: a = 0.0_dp
REAL(KIND=dp) :: b = 0.0_dp
REAL(KIND=dp) :: c = 0.0_dp
REAL(KIND=dp) :: r1 = 0.0_dp
REAL(KIND=dp) :: r2 = 0.0_dp
REAL(KIND=dp) :: r3 = 0.0_dp
INTEGER :: npoly1 = 0, npoly2 = 0
REAL(KIND=dp), DIMENSION(0:10) :: poly1 = 0.0_dp
REAL(KIND=dp), DIMENSION(0:10) :: poly2 = 0.0_dp
END TYPE buck4ran_pot_type
! **************************************************************************************************
TYPE buckmorse_pot_type
REAL(KIND=dp) :: f0 = 0.0_dp
REAL(KIND=dp) :: a1 = 0.0_dp
REAL(KIND=dp) :: a2 = 0.0_dp
REAL(KIND=dp) :: b1 = 0.0_dp
REAL(KIND=dp) :: b2 = 0.0_dp
REAL(KIND=dp) :: c = 0.0_dp
REAL(KIND=dp) :: d = 0.0_dp
REAL(KIND=dp) :: r0 = 0.0_dp
REAL(KIND=dp) :: beta = 0.0_dp
END TYPE buckmorse_pot_type
! **************************************************************************************************
TYPE gp_pot_type
INTEGER :: myid = 0
CHARACTER(LEN=default_path_length) :: potential = ""
CHARACTER(LEN=default_string_length), &
POINTER, DIMENSION(:) :: parameters => NULL(), units => NULL()
CHARACTER(LEN=default_string_length) :: variables = ""
REAL(KIND=dp), DIMENSION(:), POINTER :: values => NULL()
END TYPE gp_pot_type
! **************************************************************************************************
TYPE tersoff_pot_type
! Get this stuff from the PRB V38, N14 9902 (1988) by Tersoff
REAL(KIND=dp) :: A = 0.0_dp
REAL(KIND=dp) :: B = 0.0_dp
REAL(KIND=dp) :: lambda1 = 0.0_dp
REAL(KIND=dp) :: lambda2 = 0.0_dp
REAL(KIND=dp) :: alpha = 0.0_dp
REAL(KIND=dp) :: beta = 0.0_dp
REAL(KIND=dp) :: n = 0.0_dp
REAL(KIND=dp) :: c = 0.0_dp
REAL(KIND=dp) :: d = 0.0_dp
REAL(KIND=dp) :: h = 0.0_dp
REAL(KIND=dp) :: lambda3 = 0.0_dp
REAL(KIND=dp) :: bigR = 0.0_dp ! Used to be R = Rij + D
REAL(KIND=dp) :: bigD = 0.0_dp ! Used to be D = Rij - D
REAL(KIND=dp) :: rcutsq = 0.0_dp ! Always set to (bigR+bigD)^2
END TYPE tersoff_pot_type
! **************************************************************************************************
TYPE siepmann_pot_type
REAL(KIND=dp) :: B = 0.0_dp
REAL(KIND=dp) :: D = 0.0_dp
REAL(KIND=dp) :: E = 0.0_dp
REAL(KIND=dp) :: F = 0.0_dp
REAL(KIND=dp) :: beta = 0.0_dp
REAL(KIND=dp) :: rcutsq = 0.0_dp
LOGICAL :: allow_oh_formation = .FALSE.
LOGICAL :: allow_h3o_formation = .FALSE.
LOGICAL :: allow_o_formation = .FALSE.
END TYPE siepmann_pot_type
! **************************************************************************************************
TYPE gal_pot_type
CHARACTER(LEN=2) :: met1 = ""
CHARACTER(LEN=2) :: met2 = ""
REAL(KIND=dp) :: epsilon = 0.0_dp
REAL(KIND=dp) :: bxy = 0.0_dp
REAL(KIND=dp) :: bz = 0.0_dp
REAL(KIND=dp) :: r1 = 0.0_dp
REAL(KIND=dp) :: r2 = 0.0_dp
REAL(KIND=dp) :: a1 = 0.0_dp
REAL(KIND=dp) :: a2 = 0.0_dp
REAL(KIND=dp) :: a3 = 0.0_dp
REAL(KIND=dp) :: a4 = 0.0_dp
REAL(KIND=dp) :: a = 0.0_dp
REAL(KIND=dp) :: b = 0.0_dp
REAL(KIND=dp) :: c = 0.0_dp
REAL(KIND=dp), POINTER, DIMENSION(:) :: gcn => NULL()
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: n_vectors
REAL(KIND=dp) :: rcutsq = 0.0_dp
LOGICAL :: express = .FALSE.
END TYPE gal_pot_type
! **************************************************************************************************
TYPE gal21_pot_type
CHARACTER(LEN=2) :: met1 = ""
CHARACTER(LEN=2) :: met2 = ""
REAL(KIND=dp) :: epsilon1 = 0.0_dp
REAL(KIND=dp) :: epsilon2 = 0.0_dp
REAL(KIND=dp) :: epsilon3 = 0.0_dp
REAL(KIND=dp) :: bxy1 = 0.0_dp
REAL(KIND=dp) :: bxy2 = 0.0_dp
REAL(KIND=dp) :: bz1 = 0.0_dp
REAL(KIND=dp) :: bz2 = 0.0_dp
REAL(KIND=dp) :: r1 = 0.0_dp
REAL(KIND=dp) :: r2 = 0.0_dp
REAL(KIND=dp) :: a11 = 0.0_dp
REAL(KIND=dp) :: a12 = 0.0_dp
REAL(KIND=dp) :: a13 = 0.0_dp
REAL(KIND=dp) :: a21 = 0.0_dp
REAL(KIND=dp) :: a22 = 0.0_dp
REAL(KIND=dp) :: a23 = 0.0_dp
REAL(KIND=dp) :: a31 = 0.0_dp
REAL(KIND=dp) :: a32 = 0.0_dp
REAL(KIND=dp) :: a33 = 0.0_dp
REAL(KIND=dp) :: a41 = 0.0_dp
REAL(KIND=dp) :: a42 = 0.0_dp
REAL(KIND=dp) :: a43 = 0.0_dp
REAL(KIND=dp) :: AO1 = 0.0_dp
REAL(KIND=dp) :: AO2 = 0.0_dp
REAL(KIND=dp) :: BO1 = 0.0_dp
REAL(KIND=dp) :: BO2 = 0.0_dp
REAL(KIND=dp) :: c = 0.0_dp
REAL(KIND=dp) :: AH1 = 0.0_dp
REAL(KIND=dp) :: AH2 = 0.0_dp
REAL(KIND=dp) :: BH1 = 0.0_dp
REAL(KIND=dp) :: BH2 = 0.0_dp
REAL(KIND=dp), POINTER, DIMENSION(:) :: gcn => NULL()
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: n_vectors
REAL(KIND=dp) :: rcutsq = 0.0_dp
LOGICAL :: express = .FALSE.
END TYPE gal21_pot_type
! **************************************************************************************************
TYPE tab_pot_type
CHARACTER(LEN=default_path_length) :: tabpot_file_name = ""
INTEGER :: npoints = 0, index = 0
REAL(KIND=dp) :: dr = 0.0_dp, rcut = 0.0_dp
REAL(KIND=dp), POINTER, DIMENSION(:) :: r => NULL(), e => NULL(), f => NULL()
END TYPE tab_pot_type
! **************************************************************************************************
TYPE pot_set_type
REAL(KIND=dp) :: rmin = 0.0_dp, rmax = 0.0_dp
TYPE(ipbv_pot_type), POINTER :: ipbv => NULL()
TYPE(gp_pot_type), POINTER :: gp => NULL()
TYPE(lj_pot_type), POINTER :: lj => NULL()
TYPE(ft_pot_type), POINTER :: ft => NULL()
TYPE(williams_pot_type), POINTER :: willis => NULL()
TYPE(goodwin_pot_type), POINTER :: goodwin => NULL()
TYPE(eam_pot_type), POINTER :: eam => NULL()
TYPE(quip_pot_type), POINTER :: quip => NULL()
TYPE(nequip_pot_type), POINTER :: nequip => NULL()
TYPE(allegro_pot_type), POINTER :: allegro => NULL()
TYPE(deepmd_pot_type), POINTER :: deepmd => NULL()
TYPE(buck4ran_pot_type), POINTER :: buck4r => NULL()
TYPE(buckmorse_pot_type), POINTER :: buckmo => NULL()
TYPE(tersoff_pot_type), POINTER :: tersoff => NULL()
TYPE(siepmann_pot_type), POINTER :: siepmann => NULL()
TYPE(gal_pot_type), POINTER :: gal => NULL()
TYPE(gal21_pot_type), POINTER :: gal21 => NULL()
TYPE(ftd_pot_type), POINTER :: ftd => NULL()
TYPE(tab_pot_type), POINTER :: tab => NULL()
END TYPE pot_set_type
! **************************************************************************************************
TYPE pair_potential_single_type
REAL(KIND=dp) :: rcutsq = 0.0_dp
REAL(KIND=dp) :: e_fac = 0.0_dp
REAL(KIND=dp) :: e_fcc = 0.0_dp
REAL(KIND=dp) :: e_fcs = 0.0_dp
REAL(KIND=dp) :: e_fsc = 0.0_dp
REAL(KIND=dp) :: z1 = 0.0_dp
REAL(KIND=dp) :: z2 = 0.0_dp
REAL(KIND=dp), DIMENSION(0:5) :: zbl_poly = 0.0_dp
REAL(KIND=dp), DIMENSION(2) :: zbl_rcut = 0.0_dp
LOGICAL :: undef = .FALSE., & ! non-bonding interaction not defined
no_mb = .FALSE., & ! no many-body potential
no_pp = .FALSE. ! no pair (=two-body) potential
INTEGER :: shell_type = 0
CHARACTER(LEN=default_string_length) :: at1 = ""
CHARACTER(LEN=default_string_length) :: at2 = ""
INTEGER, POINTER, DIMENSION(:) :: TYPE => NULL()
TYPE(pot_set_type), POINTER, DIMENSION(:) :: set => NULL()
TYPE(spline_data_p_type), POINTER, DIMENSION(:) :: pair_spline_data => NULL()
TYPE(spline_factor_type), POINTER :: spl_f => NULL()
END TYPE pair_potential_single_type
! **************************************************************************************************
TYPE pair_potential_type
TYPE(pair_potential_single_type), POINTER :: pot => NULL()
END TYPE pair_potential_type
! **************************************************************************************************
TYPE pair_potential_p_type
TYPE(pair_potential_type), DIMENSION(:), POINTER :: pot => NULL()
END TYPE pair_potential_p_type
! **************************************************************************************************
TYPE pair_potential_pp_type
TYPE(pair_potential_type), DIMENSION(:, :), POINTER :: pot => NULL()
END TYPE pair_potential_pp_type
CONTAINS
! **************************************************************************************************
!> \brief compare two different potentials
!> \param pot1 ...
!> \param pot2 ...
!> \param compare ...
!> \author Teodoro Laino [teo] 05.2006
! **************************************************************************************************
SUBROUTINE compare_pot(pot1, pot2, compare)
TYPE(pair_potential_single_type), POINTER :: pot1, pot2
LOGICAL, INTENT(OUT) :: compare
INTEGER :: i
LOGICAL :: mycompare
compare = .FALSE.
! Preliminary checks
CPASSERT(ASSOCIATED(pot1%type))
CPASSERT(ASSOCIATED(pot2%type))
IF (SIZE(pot1%type) /= SIZE(pot2%type)) RETURN
IF (ANY(pot1%type /= pot2%type)) RETURN
! Checking the real values of parameters
CPASSERT(ASSOCIATED(pot1%set))
CPASSERT(ASSOCIATED(pot2%set))
DO i = 1, SIZE(pot1%type)
mycompare = .FALSE.
SELECT CASE (pot1%type(i))
CASE (lj_type, lj_charmm_type)
IF ((pot1%set(i)%lj%epsilon == pot2%set(i)%lj%epsilon) .AND. &
(pot1%set(i)%lj%sigma6 == pot2%set(i)%lj%sigma6) .AND. &
(pot1%set(i)%lj%sigma12 == pot2%set(i)%lj%sigma12)) mycompare = .TRUE.
CASE (wl_type)
IF ((pot1%set(i)%willis%a == pot2%set(i)%willis%a) .AND. &
(pot1%set(i)%willis%b == pot2%set(i)%willis%b) .AND. &
(pot1%set(i)%willis%c == pot2%set(i)%willis%c)) mycompare = .TRUE.
CASE (gw_type)
IF ((pot1%set(i)%goodwin%vr0 == pot2%set(i)%goodwin%vr0) .AND. &
(pot1%set(i)%goodwin%m == pot2%set(i)%goodwin%m) .AND. &
(pot1%set(i)%goodwin%mc == pot2%set(i)%goodwin%mc) .AND. &
(pot1%set(i)%goodwin%d == pot2%set(i)%goodwin%d) .AND. &
(pot1%set(i)%goodwin%dc == pot2%set(i)%goodwin%dc)) mycompare = .TRUE.
CASE (ea_type)
! Compare only if EAM have the same number of points
IF (pot1%set(i)%eam%npoints == pot2%set(i)%eam%npoints) THEN
IF ((pot1%set(i)%eam%drar == pot2%set(i)%eam%drar) .AND. &
(pot1%set(i)%eam%drhoar == pot2%set(i)%eam%drhoar) .AND. &
(pot1%set(i)%eam%acutal == pot2%set(i)%eam%acutal) .AND. &
(SUM(ABS(pot1%set(i)%eam%rho - pot2%set(i)%eam%rho)) == 0.0_dp) .AND. &
(SUM(ABS(pot1%set(i)%eam%phi - pot2%set(i)%eam%phi)) == 0.0_dp) .AND. &
(SUM(ABS(pot1%set(i)%eam%frho - pot2%set(i)%eam%frho)) == 0.0_dp) .AND. &
(SUM(ABS(pot1%set(i)%eam%rhoval - pot2%set(i)%eam%rhoval)) == 0.0_dp) .AND. &
(SUM(ABS(pot1%set(i)%eam%rval - pot2%set(i)%eam%rval)) == 0.0_dp) .AND. &
(SUM(ABS(pot1%set(i)%eam%rhop - pot2%set(i)%eam%rhop)) == 0.0_dp) .AND. &
(SUM(ABS(pot1%set(i)%eam%phip - pot2%set(i)%eam%phip)) == 0.0_dp) .AND. &
(SUM(ABS(pot1%set(i)%eam%frhop - pot2%set(i)%eam%frhop)) == 0.0_dp)) mycompare = .TRUE.
END IF
CASE (deepmd_type)
IF ((pot1%set(i)%deepmd%deepmd_file_name == pot2%set(i)%deepmd%deepmd_file_name) .AND. &
(pot1%set(i)%deepmd%atom_deepmd_type == pot2%set(i)%deepmd%atom_deepmd_type)) mycompare = .TRUE.
CASE (quip_type)
IF ((pot1%set(i)%quip%quip_file_name == pot2%set(i)%quip%quip_file_name) .AND. &
(pot1%set(i)%quip%init_args == pot2%set(i)%quip%init_args) .AND. &
(pot1%set(i)%quip%calc_args == pot2%set(i)%quip%calc_args)) mycompare = .TRUE.
CASE (nequip_type)
IF ((pot1%set(i)%nequip%nequip_file_name == pot2%set(i)%nequip%nequip_file_name) .AND. &
(pot1%set(i)%nequip%unit_coords == pot2%set(i)%nequip%unit_coords) .AND. &
(pot1%set(i)%nequip%unit_forces == pot2%set(i)%nequip%unit_forces) .AND. &
(pot1%set(i)%nequip%unit_energy == pot2%set(i)%nequip%unit_energy) .AND. &
(pot1%set(i)%nequip%unit_cell == pot2%set(i)%nequip%unit_cell)) mycompare = .TRUE.
CASE (allegro_type)
IF ((pot1%set(i)%allegro%allegro_file_name == pot2%set(i)%allegro%allegro_file_name) .AND. &
(pot1%set(i)%allegro%unit_coords == pot2%set(i)%allegro%unit_coords) .AND. &
(pot1%set(i)%allegro%unit_forces == pot2%set(i)%allegro%unit_forces) .AND. &
(pot1%set(i)%allegro%unit_energy == pot2%set(i)%allegro%unit_energy) .AND. &
(pot1%set(i)%allegro%unit_cell == pot2%set(i)%allegro%unit_cell)) mycompare = .TRUE.
CASE (ft_type)
IF ((pot1%set(i)%ft%A == pot2%set(i)%ft%A) .AND. &
(pot1%set(i)%ft%B == pot2%set(i)%ft%B) .AND. &
(pot1%set(i)%ft%C == pot2%set(i)%ft%C) .AND. &
(pot1%set(i)%ft%D == pot2%set(i)%ft%D)) mycompare = .TRUE.
CASE (ftd_type)
IF ((pot1%set(i)%ftd%A == pot2%set(i)%ftd%A) .AND. &
(pot1%set(i)%ftd%B == pot2%set(i)%ftd%B) .AND. &
(pot1%set(i)%ftd%C == pot2%set(i)%ftd%C) .AND. &
(pot1%set(i)%ftd%D == pot2%set(i)%ftd%D) .AND. &
(ALL(pot1%set(i)%ftd%BD(:) == pot2%set(i)%ftd%BD(:)))) mycompare = .TRUE.
CASE (ip_type)
IF ((SUM(ABS(pot1%set(i)%ipbv%a - pot2%set(i)%ipbv%a)) == 0.0_dp) .AND. &
(pot1%set(i)%ipbv%rcore == pot2%set(i)%ipbv%rcore) .AND. &
(pot1%set(i)%ipbv%m == pot2%set(i)%ipbv%m) .AND. &
(pot1%set(i)%ipbv%b == pot2%set(i)%ipbv%b)) mycompare = .TRUE.
CASE (tersoff_type)
IF ((pot1%set(i)%tersoff%A == pot2%set(i)%tersoff%A) .AND. &
(pot1%set(i)%tersoff%B == pot2%set(i)%tersoff%B) .AND. &
(pot1%set(i)%tersoff%lambda1 == pot2%set(i)%tersoff%lambda1) .AND. &
(pot1%set(i)%tersoff%lambda2 == pot2%set(i)%tersoff%lambda2) .AND. &
(pot1%set(i)%tersoff%alpha == pot2%set(i)%tersoff%alpha) .AND. &
(pot1%set(i)%tersoff%beta == pot2%set(i)%tersoff%beta) .AND. &
(pot1%set(i)%tersoff%n == pot2%set(i)%tersoff%n) .AND. &
(pot1%set(i)%tersoff%c == pot2%set(i)%tersoff%c) .AND. &
(pot1%set(i)%tersoff%d == pot2%set(i)%tersoff%d) .AND. &
(pot1%set(i)%tersoff%h == pot2%set(i)%tersoff%h) .AND. &
(pot1%set(i)%tersoff%lambda3 == pot2%set(i)%tersoff%lambda3) .AND. &
(pot1%set(i)%tersoff%rcutsq == pot2%set(i)%tersoff%rcutsq) .AND. &
(pot1%set(i)%tersoff%bigR == pot2%set(i)%tersoff%bigR) .AND. &
(pot1%set(i)%tersoff%bigD == pot2%set(i)%tersoff%bigD)) mycompare = .TRUE.
CASE (siepmann_type)
IF ((pot1%set(i)%siepmann%B == pot2%set(i)%siepmann%B) .AND. &
(pot1%set(i)%siepmann%D == pot2%set(i)%siepmann%D) .AND. &
(pot1%set(i)%siepmann%E == pot2%set(i)%siepmann%E) .AND. &
(pot1%set(i)%siepmann%F == pot2%set(i)%siepmann%F) .AND. &
(pot1%set(i)%siepmann%beta == pot2%set(i)%siepmann%beta) .AND. &
(pot1%set(i)%siepmann%rcutsq == pot2%set(i)%siepmann%rcutsq) .AND. &
(pot1%set(i)%siepmann%allow_oh_formation .EQV. &
pot2%set(i)%siepmann%allow_oh_formation) .AND. &
(pot1%set(i)%siepmann%allow_o_formation .EQV. &
pot2%set(i)%siepmann%allow_o_formation) .AND. &
(pot1%set(i)%siepmann%allow_h3o_formation .EQV. &
pot2%set(i)%siepmann%allow_h3o_formation)) mycompare = .TRUE.
CASE (gal_type)
IF ((pot1%set(i)%gal%epsilon == pot2%set(i)%gal%epsilon) .AND. &
(pot1%set(i)%gal%bxy == pot2%set(i)%gal%bxy) .AND. &
(pot1%set(i)%gal%bz == pot2%set(i)%gal%bz) .AND. &
(pot1%set(i)%gal%r1 == pot2%set(i)%gal%r1) .AND. &
(pot1%set(i)%gal%r2 == pot2%set(i)%gal%r2) .AND. &
(pot1%set(i)%gal%a1 == pot2%set(i)%gal%a1) .AND. &
(pot1%set(i)%gal%a2 == pot2%set(i)%gal%a2) .AND. &
(pot1%set(i)%gal%a3 == pot2%set(i)%gal%a3) .AND. &
(pot1%set(i)%gal%a4 == pot2%set(i)%gal%a4) .AND. &
(pot1%set(i)%gal%a == pot2%set(i)%gal%a) .AND. &
(pot1%set(i)%gal%b == pot2%set(i)%gal%b) .AND. &
(pot1%set(i)%gal%c == pot2%set(i)%gal%c) .AND. &
(pot1%set(i)%gal%express .EQV. &
pot2%set(i)%gal%express) .AND. &
(pot1%set(i)%gal%rcutsq == pot2%set(i)%gal%rcutsq)) mycompare = .TRUE.
CASE (gal21_type)
IF ((pot1%set(i)%gal21%epsilon1 == pot2%set(i)%gal21%epsilon1) .AND. &
(pot1%set(i)%gal21%epsilon2 == pot2%set(i)%gal21%epsilon2) .AND. &
(pot1%set(i)%gal21%epsilon3 == pot2%set(i)%gal21%epsilon3) .AND. &
(pot1%set(i)%gal21%bxy1 == pot2%set(i)%gal21%bxy1) .AND. &
(pot1%set(i)%gal21%bxy2 == pot2%set(i)%gal21%bxy1) .AND. &
(pot1%set(i)%gal21%bz1 == pot2%set(i)%gal21%bz1) .AND. &
(pot1%set(i)%gal21%bz2 == pot2%set(i)%gal21%bz2) .AND. &
(pot1%set(i)%gal21%r1 == pot2%set(i)%gal21%r1) .AND. &
(pot1%set(i)%gal21%r2 == pot2%set(i)%gal21%r2) .AND. &
(pot1%set(i)%gal21%a11 == pot2%set(i)%gal21%a11) .AND. &
(pot1%set(i)%gal21%a12 == pot2%set(i)%gal21%a12) .AND. &
(pot1%set(i)%gal21%a13 == pot2%set(i)%gal21%a13) .AND. &
(pot1%set(i)%gal21%a21 == pot2%set(i)%gal21%a21) .AND. &
(pot1%set(i)%gal21%a22 == pot2%set(i)%gal21%a22) .AND. &
(pot1%set(i)%gal21%a23 == pot2%set(i)%gal21%a23) .AND. &
(pot1%set(i)%gal21%a31 == pot2%set(i)%gal21%a31) .AND. &
(pot1%set(i)%gal21%a32 == pot2%set(i)%gal21%a32) .AND. &
(pot1%set(i)%gal21%a33 == pot2%set(i)%gal21%a33) .AND. &
(pot1%set(i)%gal21%a41 == pot2%set(i)%gal21%a41) .AND. &
(pot1%set(i)%gal21%a42 == pot2%set(i)%gal21%a42) .AND. &
(pot1%set(i)%gal21%a43 == pot2%set(i)%gal21%a43) .AND. &
(pot1%set(i)%gal21%AO1 == pot2%set(i)%gal21%AO1) .AND. &
(pot1%set(i)%gal21%AO2 == pot2%set(i)%gal21%AO2) .AND. &
(pot1%set(i)%gal21%BO1 == pot2%set(i)%gal21%BO1) .AND. &
(pot1%set(i)%gal21%BO2 == pot2%set(i)%gal21%BO2) .AND. &
(pot1%set(i)%gal21%c == pot2%set(i)%gal21%c) .AND. &
(pot1%set(i)%gal21%AH1 == pot2%set(i)%gal21%AH1) .AND. &
(pot1%set(i)%gal21%AH2 == pot2%set(i)%gal21%AH2) .AND. &
(pot1%set(i)%gal21%BH1 == pot2%set(i)%gal21%BH1) .AND. &
(pot1%set(i)%gal21%BH2 == pot2%set(i)%gal21%BH2) .AND. &
(pot1%set(i)%gal21%express .EQV. &
pot2%set(i)%gal21%express) .AND. &
(pot1%set(i)%gal21%rcutsq == pot2%set(i)%gal21%rcutsq)) mycompare = .TRUE.
END SELECT
mycompare = mycompare .AND. &
(pot1%set(i)%rmin == pot2%set(i)%rmin) .AND. (pot1%set(i)%rmax == pot2%set(i)%rmax)
IF ((mycompare) .AND. (i == 1)) compare = .TRUE.
compare = compare .AND. mycompare
END DO
END SUBROUTINE compare_pot
! **************************************************************************************************
!> \brief Creates the potential parameter type
!> \param potparm ...
!> \param nset ...
!> \author Teodoro Laino [teo] 11.2005
! **************************************************************************************************
SUBROUTINE pair_potential_single_create(potparm, nset)
TYPE(pair_potential_single_type), POINTER :: potparm
INTEGER, INTENT(IN), OPTIONAL :: nset
INTEGER :: i, lnset
CPASSERT(.NOT. ASSOCIATED(potparm))
ALLOCATE (potparm)
lnset = 1
IF (PRESENT(nset)) lnset = nset
! Standard allocation to size 1
ALLOCATE (potparm%type(lnset))
ALLOCATE (potparm%set(lnset))
NULLIFY (potparm%spl_f, &
potparm%pair_spline_data)
DO i = 1, lnset
potparm%set(i)%rmin = not_initialized
potparm%set(i)%rmax = not_initialized
NULLIFY (potparm%set(i)%ipbv, &
potparm%set(i)%lj, &
potparm%set(i)%gp, &
potparm%set(i)%ft, &
potparm%set(i)%willis, &
potparm%set(i)%goodwin, &
potparm%set(i)%eam, &
potparm%set(i)%quip, &
potparm%set(i)%nequip, &
potparm%set(i)%allegro, &
potparm%set(i)%deepmd, &
potparm%set(i)%buck4r, &
potparm%set(i)%buckmo, &
potparm%set(i)%tersoff, &
potparm%set(i)%siepmann, &
potparm%set(i)%gal, &
potparm%set(i)%gal21, &
potparm%set(i)%ftd, &
potparm%set(i)%tab)
END DO
CALL pair_potential_single_clean(potparm)
END SUBROUTINE pair_potential_single_create
! **************************************************************************************************
!> \brief Cleans the potential parameter type
!> \param potparm ...
!> \author unknown
! **************************************************************************************************
SUBROUTINE pair_potential_single_clean(potparm)
TYPE(pair_potential_single_type), POINTER :: potparm
INTEGER :: i
potparm%type = nn_type
potparm%shell_type = nosh_nosh
potparm%undef = .TRUE.
potparm%no_pp = .FALSE.
potparm%no_mb = .FALSE.
potparm%at1 = 'NULL'
potparm%at2 = 'NULL'
potparm%rcutsq = 0.0_dp
IF (ASSOCIATED(potparm%pair_spline_data)) &
CALL spline_data_p_release(potparm%pair_spline_data)
IF (ASSOCIATED(potparm%spl_f)) &
CALL spline_factor_release(potparm%spl_f)
DO i = 1, SIZE(potparm%type)
potparm%set(i)%rmin = not_initialized
potparm%set(i)%rmax = not_initialized
CALL pair_potential_lj_clean(potparm%set(i)%lj)
CALL pair_potential_williams_clean(potparm%set(i)%willis)
CALL pair_potential_goodwin_clean(potparm%set(i)%goodwin)
CALL pair_potential_eam_clean(potparm%set(i)%eam)
CALL pair_potential_quip_clean(potparm%set(i)%quip)
CALL pair_potential_nequip_clean(potparm%set(i)%nequip)
CALL pair_potential_allegro_clean(potparm%set(i)%allegro)
CALL pair_potential_deepmd_clean(potparm%set(i)%deepmd)
CALL pair_potential_buck4r_clean(potparm%set(i)%buck4r)
CALL pair_potential_buckmo_clean(potparm%set(i)%buckmo)
CALL pair_potential_bmhft_clean(potparm%set(i)%ft)
CALL pair_potential_bmhftd_clean(potparm%set(i)%ftd)
CALL pair_potential_ipbv_clean(potparm%set(i)%ipbv)
CALL pair_potential_gp_clean(potparm%set(i)%gp)
CALL pair_potential_tersoff_clean(potparm%set(i)%tersoff)
CALL pair_potential_siepmann_clean(potparm%set(i)%siepmann)
CALL pair_potential_gal_clean(potparm%set(i)%gal)
CALL pair_potential_gal21_clean(potparm%set(i)%gal21)
CALL pair_potential_tab_clean(potparm%set(i)%tab)
END DO
END SUBROUTINE pair_potential_single_clean
! **************************************************************************************************
!> \brief Copy two potential parameter type
!> \param potparm_source ...
!> \param potparm_dest ...
!> \author Teodoro Laino [teo] 11.2005
! **************************************************************************************************
SUBROUTINE pair_potential_single_copy(potparm_source, potparm_dest)
TYPE(pair_potential_single_type), POINTER :: potparm_source, potparm_dest
INTEGER :: i
CPASSERT(ASSOCIATED(potparm_source))
IF (.NOT. ASSOCIATED(potparm_dest)) THEN
CALL pair_potential_single_create(potparm_dest, SIZE(potparm_source%type))
ELSE
CALL pair_potential_single_clean(potparm_dest)
END IF
potparm_dest%type = potparm_source%type
potparm_dest%shell_type = potparm_source%shell_type
potparm_dest%undef = potparm_source%undef
potparm_dest%no_mb = potparm_source%no_mb
potparm_dest%no_pp = potparm_source%no_pp
potparm_dest%at1 = potparm_source%at1
potparm_dest%at2 = potparm_source%at2
potparm_dest%rcutsq = potparm_source%rcutsq
IF (ASSOCIATED(potparm_source%pair_spline_data)) THEN
CALL spline_data_p_copy(potparm_source%pair_spline_data, potparm_dest%pair_spline_data)
END IF
IF (ASSOCIATED(potparm_source%spl_f)) THEN
CALL spline_factor_copy(potparm_source%spl_f, potparm_dest%spl_f)
END IF
DO i = 1, SIZE(potparm_source%type)
potparm_dest%set(i)%rmin = potparm_source%set(i)%rmin
potparm_dest%set(i)%rmax = potparm_source%set(i)%rmax
CALL pair_potential_lj_copy(potparm_source%set(i)%lj, potparm_dest%set(i)%lj)
CALL pair_potential_williams_copy(potparm_source%set(i)%willis, potparm_dest%set(i)%willis)
CALL pair_potential_goodwin_copy(potparm_source%set(i)%goodwin, potparm_dest%set(i)%goodwin)
CALL pair_potential_eam_copy(potparm_source%set(i)%eam, potparm_dest%set(i)%eam)
CALL pair_potential_quip_copy(potparm_source%set(i)%quip, potparm_dest%set(i)%quip)
CALL pair_potential_nequip_copy(potparm_source%set(i)%nequip, potparm_dest%set(i)%nequip)
CALL pair_potential_allegro_copy(potparm_source%set(i)%allegro, potparm_dest%set(i)%allegro)
CALL pair_potential_deepmd_copy(potparm_source%set(i)%deepmd, potparm_dest%set(i)%deepmd)
CALL pair_potential_bmhft_copy(potparm_source%set(i)%ft, potparm_dest%set(i)%ft)
CALL pair_potential_bmhftd_copy(potparm_source%set(i)%ftd, potparm_dest%set(i)%ftd)
CALL pair_potential_ipbv_copy(potparm_source%set(i)%ipbv, potparm_dest%set(i)%ipbv)
CALL pair_potential_buck4r_copy(potparm_source%set(i)%buck4r, potparm_dest%set(i)%buck4r)
CALL pair_potential_buckmo_copy(potparm_source%set(i)%buckmo, potparm_dest%set(i)%buckmo)
CALL pair_potential_gp_copy(potparm_source%set(i)%gp, potparm_dest%set(i)%gp)
CALL pair_potential_tersoff_copy(potparm_source%set(i)%tersoff, potparm_dest%set(i)%tersoff)
CALL pair_potential_siepmann_copy(potparm_source%set(i)%siepmann, potparm_dest%set(i)%siepmann)
CALL pair_potential_gal_copy(potparm_source%set(i)%gal, potparm_dest%set(i)%gal)
CALL pair_potential_gal21_copy(potparm_source%set(i)%gal21, potparm_dest%set(i)%gal21)
CALL pair_potential_tab_copy(potparm_source%set(i)%tab, potparm_dest%set(i)%tab)
END DO
END SUBROUTINE pair_potential_single_copy
! **************************************************************************************************
!> \brief Add potential parameter type to an existing potential parameter type
!> Used in case of multiple_potential definition
!> \param potparm_source ...
!> \param potparm_dest ...
!> \author Teodoro Laino [teo] 11.2005
! **************************************************************************************************
SUBROUTINE pair_potential_single_add(potparm_source, potparm_dest)
TYPE(pair_potential_single_type), POINTER :: potparm_source, potparm_dest
INTEGER :: i, j, size_dest, size_source
LOGICAL :: allocate_new, check
TYPE(pair_potential_single_type), POINTER :: potparm_tmp
CPASSERT(ASSOCIATED(potparm_source))
! At this level we expect all splines types
! be not allocated.. No sense add splines at this level.. in case fail!
check = (.NOT. ASSOCIATED(potparm_source%pair_spline_data)) .AND. &
(.NOT. ASSOCIATED(potparm_source%spl_f))
CPASSERT(check)
check = (.NOT. ASSOCIATED(potparm_dest%pair_spline_data)) .AND. &
(.NOT. ASSOCIATED(potparm_dest%spl_f))
CPASSERT(check)
! Increase the size of the destination potparm (in case) and copy the new data
size_source = SIZE(potparm_source%type)
allocate_new = .NOT. ASSOCIATED(potparm_dest)
IF (.NOT. allocate_new) THEN
size_dest = SIZE(potparm_dest%type)
IF (size_dest == 1) THEN
check = (ASSOCIATED(potparm_dest%set(1)%lj)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%willis)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%goodwin)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%eam)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%quip)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%nequip)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%allegro)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%deepmd)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%ft)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%ftd)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%ipbv)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%buck4r)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%buckmo)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%gp)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%tersoff)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%siepmann)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%gal)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%gal)) .OR. &
(ASSOCIATED(potparm_dest%set(1)%tab))
IF (.NOT. check) THEN
allocate_new = .TRUE.
CALL pair_potential_single_release(potparm_dest)
END IF
END IF
END IF
IF (allocate_new) THEN
size_dest = 0
CALL pair_potential_single_create(potparm_dest, size_source)
potparm_dest%shell_type = potparm_source%shell_type
potparm_dest%undef = potparm_source%undef
potparm_dest%no_mb = potparm_source%no_mb
potparm_dest%no_pp = potparm_source%no_pp
potparm_dest%at1 = potparm_source%at1
potparm_dest%at2 = potparm_source%at2
potparm_dest%rcutsq = potparm_source%rcutsq
ELSE
size_dest = SIZE(potparm_dest%type)
NULLIFY (potparm_tmp)
CALL pair_potential_single_copy(potparm_dest, potparm_tmp)
CALL pair_potential_single_release(potparm_dest)
CALL pair_potential_single_create(potparm_dest, size_dest + size_source)
! Copy back original informations..
potparm_dest%shell_type = potparm_tmp%shell_type
potparm_dest%undef = potparm_tmp%undef
potparm_dest%no_mb = potparm_tmp%no_mb
potparm_dest%no_pp = potparm_tmp%no_pp
potparm_dest%at1 = potparm_tmp%at1
potparm_dest%at2 = potparm_tmp%at2
potparm_dest%rcutsq = potparm_tmp%rcutsq
DO i = 1, size_dest
potparm_dest%type(i) = potparm_tmp%type(i)
potparm_dest%set(i)%rmin = potparm_tmp%set(i)%rmin
potparm_dest%set(i)%rmax = potparm_tmp%set(i)%rmax
CALL pair_potential_lj_copy(potparm_tmp%set(i)%lj, potparm_dest%set(i)%lj)
CALL pair_potential_williams_copy(potparm_tmp%set(i)%willis, potparm_dest%set(i)%willis)
CALL pair_potential_goodwin_copy(potparm_tmp%set(i)%goodwin, potparm_dest%set(i)%goodwin)
CALL pair_potential_eam_copy(potparm_tmp%set(i)%eam, potparm_dest%set(i)%eam)
CALL pair_potential_quip_copy(potparm_tmp%set(i)%quip, potparm_dest%set(i)%quip)
CALL pair_potential_nequip_copy(potparm_tmp%set(i)%nequip, potparm_dest%set(i)%nequip)
CALL pair_potential_allegro_copy(potparm_tmp%set(i)%allegro, potparm_dest%set(i)%allegro)
CALL pair_potential_deepmd_copy(potparm_tmp%set(i)%deepmd, potparm_dest%set(i)%deepmd)
CALL pair_potential_bmhft_copy(potparm_tmp%set(i)%ft, potparm_dest%set(i)%ft)
CALL pair_potential_bmhftd_copy(potparm_tmp%set(i)%ftd, potparm_dest%set(i)%ftd)
CALL pair_potential_ipbv_copy(potparm_tmp%set(i)%ipbv, potparm_dest%set(i)%ipbv)
CALL pair_potential_buck4r_copy(potparm_tmp%set(i)%buck4r, potparm_dest%set(i)%buck4r)
CALL pair_potential_buckmo_copy(potparm_tmp%set(i)%buckmo, potparm_dest%set(i)%buckmo)
CALL pair_potential_gp_copy(potparm_tmp%set(i)%gp, potparm_dest%set(i)%gp)
CALL pair_potential_tersoff_copy(potparm_tmp%set(i)%tersoff, potparm_dest%set(i)%tersoff)
CALL pair_potential_siepmann_copy(potparm_tmp%set(i)%siepmann, potparm_dest%set(i)%siepmann)
CALL pair_potential_gal_copy(potparm_tmp%set(i)%gal, potparm_dest%set(i)%gal)
CALL pair_potential_gal21_copy(potparm_tmp%set(i)%gal21, potparm_dest%set(i)%gal21)
CALL pair_potential_tab_copy(potparm_tmp%set(i)%tab, potparm_dest%set(i)%tab)
END DO
CALL pair_potential_single_release(potparm_tmp)
END IF
! Further check with main option with source and dest (already filled with few informations)
check = (potparm_dest%shell_type == potparm_source%shell_type) .AND. &
(potparm_dest%undef .EQV. potparm_source%undef) .AND. &
(potparm_dest%no_mb .EQV. potparm_source%no_mb) .AND. &
(potparm_dest%no_pp .EQV. potparm_source%no_pp) .AND. &
(potparm_dest%at1 == potparm_source%at1) .AND. &
(potparm_dest%at2 == potparm_source%at2) .AND. &
(potparm_dest%rcutsq == potparm_source%rcutsq)
CPASSERT(check)
! Now copy the new pair_potential type
DO i = size_dest + 1, size_dest + size_source
j = i - size_dest
potparm_dest%type(i) = potparm_source%type(j)
potparm_dest%set(i)%rmin = potparm_source%set(j)%rmin
potparm_dest%set(i)%rmax = potparm_source%set(j)%rmax
CALL pair_potential_lj_copy(potparm_source%set(j)%lj, potparm_dest%set(i)%lj)
CALL pair_potential_williams_copy(potparm_source%set(j)%willis, potparm_dest%set(i)%willis)
CALL pair_potential_goodwin_copy(potparm_source%set(j)%goodwin, potparm_dest%set(i)%goodwin)
CALL pair_potential_eam_copy(potparm_source%set(j)%eam, potparm_dest%set(i)%eam)
CALL pair_potential_quip_copy(potparm_source%set(j)%quip, potparm_dest%set(i)%quip)
CALL pair_potential_nequip_copy(potparm_source%set(j)%nequip, potparm_dest%set(i)%nequip)
CALL pair_potential_allegro_copy(potparm_source%set(j)%allegro, potparm_dest%set(i)%allegro)
CALL pair_potential_deepmd_copy(potparm_source%set(j)%deepmd, potparm_dest%set(i)%deepmd)
CALL pair_potential_bmhft_copy(potparm_source%set(j)%ft, potparm_dest%set(i)%ft)
CALL pair_potential_bmhftd_copy(potparm_source%set(j)%ftd, potparm_dest%set(i)%ftd)
CALL pair_potential_ipbv_copy(potparm_source%set(j)%ipbv, potparm_dest%set(i)%ipbv)
CALL pair_potential_buck4r_copy(potparm_source%set(j)%buck4r, potparm_dest%set(i)%buck4r)
CALL pair_potential_buckmo_copy(potparm_source%set(j)%buckmo, potparm_dest%set(i)%buckmo)
CALL pair_potential_gp_copy(potparm_source%set(j)%gp, potparm_dest%set(i)%gp)
CALL pair_potential_tersoff_copy(potparm_source%set(j)%tersoff, potparm_dest%set(i)%tersoff)
CALL pair_potential_siepmann_copy(potparm_source%set(j)%siepmann, potparm_dest%set(i)%siepmann)
CALL pair_potential_gal_copy(potparm_source%set(j)%gal, potparm_dest%set(i)%gal)
CALL pair_potential_gal21_copy(potparm_source%set(j)%gal21, potparm_dest%set(i)%gal21)
CALL pair_potential_tab_copy(potparm_source%set(j)%tab, potparm_dest%set(i)%tab)
END DO
END SUBROUTINE pair_potential_single_add
! **************************************************************************************************
!> \brief Release Data-structure that constains potential parameters of a single pair
!> \param potparm ...
!> \author Teodoro Laino [Teo] 11.2005
! **************************************************************************************************
SUBROUTINE pair_potential_single_release(potparm)
TYPE(pair_potential_single_type), POINTER :: potparm
INTEGER :: i
CPASSERT(ASSOCIATED(potparm))
CALL spline_data_p_release(potparm%pair_spline_data)
CALL spline_factor_release(potparm%spl_f)
DO i = 1, SIZE(potparm%type)
CALL pair_potential_ipbv_release(potparm%set(i)%ipbv)
CALL pair_potential_lj_release(potparm%set(i)%lj)
CALL pair_potential_bmhft_release(potparm%set(i)%ft)
CALL pair_potential_bmhftd_release(potparm%set(i)%ftd)
CALL pair_potential_williams_release(potparm%set(i)%willis)
CALL pair_potential_goodwin_release(potparm%set(i)%goodwin)
CALL pair_potential_eam_release(potparm%set(i)%eam)
CALL pair_potential_quip_release(potparm%set(i)%quip)
CALL pair_potential_nequip_release(potparm%set(i)%nequip)
CALL pair_potential_allegro_release(potparm%set(i)%allegro)
CALL pair_potential_deepmd_release(potparm%set(i)%deepmd)
CALL pair_potential_buck4r_release(potparm%set(i)%buck4r)
CALL pair_potential_buckmo_release(potparm%set(i)%buckmo)
CALL pair_potential_gp_release(potparm%set(i)%gp)
CALL pair_potential_tersoff_release(potparm%set(i)%tersoff)
CALL pair_potential_siepmann_release(potparm%set(i)%siepmann)
CALL pair_potential_gal_release(potparm%set(i)%gal)
CALL pair_potential_gal21_release(potparm%set(i)%gal21)
CALL pair_potential_tab_release(potparm%set(i)%tab)
END DO
DEALLOCATE (potparm%type)
DEALLOCATE (potparm%set)
DEALLOCATE (potparm)
END SUBROUTINE pair_potential_single_release
! **************************************************************************************************
!> \brief Data-structure that constains potential parameters
!> \param potparm ...
!> \param nkinds ...
!> \author unknown
! **************************************************************************************************
SUBROUTINE pair_potential_pp_create(potparm, nkinds)
TYPE(pair_potential_pp_type), POINTER :: potparm
INTEGER, INTENT(IN) :: nkinds
INTEGER :: i, j
CPASSERT(.NOT. ASSOCIATED(potparm))
ALLOCATE (potparm)
ALLOCATE (potparm%pot(nkinds, nkinds))
DO i = 1, nkinds
DO j = 1, nkinds
NULLIFY (potparm%pot(i, j)%pot)
END DO
END DO
! Use no-redundancy in the potential definition
DO i = 1, nkinds
DO j = i, nkinds
CALL pair_potential_single_create(potparm%pot(i, j)%pot)
potparm%pot(j, i)%pot => potparm%pot(i, j)%pot
END DO
END DO
END SUBROUTINE pair_potential_pp_create
! **************************************************************************************************
!> \brief Release Data-structure that constains potential parameters
!> \param potparm ...
!> \par History
!> Teodoro Laino [Teo] 11.2005 : Reorganizing the structures to optimize
!> memory management
!> \author unknown
! **************************************************************************************************
SUBROUTINE pair_potential_pp_release(potparm)
TYPE(pair_potential_pp_type), POINTER :: potparm
INTEGER :: i, j
IF (ASSOCIATED(potparm)) THEN
IF (ASSOCIATED(potparm%pot)) THEN
DO i = 1, SIZE(potparm%pot, 1)
DO j = i, SIZE(potparm%pot, 2)
CALL pair_potential_single_release(potparm%pot(i, j)%pot)
NULLIFY (potparm%pot(j, i)%pot)
END DO
END DO
DEALLOCATE (potparm%pot)
END IF
DEALLOCATE (potparm)
END IF
NULLIFY (potparm)
END SUBROUTINE pair_potential_pp_release
! **************************************************************************************************
!> \brief Data-structure that constains potential parameters
!> \param potparm ...
!> \param ndim ...
!> \param ub ...
!> \param lb ...
!> \author unknown
! **************************************************************************************************
SUBROUTINE pair_potential_p_create(potparm, ndim, ub, lb)