22 integer,
parameter ::
dp = kind(1.0d0)
38 integer,
allocatable :: hindex(:,:)
41 type(bml_matrix_t) :: ham
44 type(bml_matrix_t) :: hamaux
47 type(bml_matrix_t) :: ham0
50 type(bml_matrix_t) :: oham
53 type(bml_matrix_t) :: ohamaux
56 type(bml_matrix_t) :: over
59 type(bml_matrix_t) :: rho
62 type(bml_matrix_t) :: orho
65 type(bml_matrix_t) :: zmat
68 type(bml_matrix_t) :: evects
71 type(bml_matrix_t) :: mat
74 type(bml_matrix_t) :: mataux
77 real(
dp),
allocatable :: coul_pot_r(:)
80 real(
dp),
allocatable :: coul_pot_k(:)
83 real(
dp),
allocatable :: skforce(:,:)
86 real(
dp),
allocatable :: fpul(:,:)
89 real(
dp),
allocatable :: fscoul(:,:)
92 real(
dp),
allocatable :: aux(:,:)
95 real(
dp),
allocatable :: evals(:)
98 real(
dp),
allocatable :: dvals(:)
101 real(
dp),
allocatable :: ker(:,:)
104 integer :: norbsincore
123 character(2),
allocatable :: symbol(:)
126 integer,
allocatable :: atomic_number(:)
131 real(
dp),
allocatable :: coordinate(:,:)
136 real(
dp),
allocatable :: velocity(:,:)
141 real(
dp),
allocatable :: force(:,:)
146 real(
dp),
allocatable :: net_charge(:)
153 real(
dp),
allocatable :: mass(:)
163 real(
dp),
allocatable :: lattice_vector(:,:)
171 real(
dp),
allocatable :: recip_vector(:,:)
194 integer,
allocatable :: spindex(:)
202 character(2),
allocatable :: splist(:)
209 integer,
allocatable :: spatnum(:)
215 real(
dp),
allocatable :: spmass(:)
218 real(
dp),
allocatable :: userdef(:)
221 integer,
allocatable :: resindex(:)
224 character(3),
allocatable :: resname(:)
227 character(3),
allocatable :: atomname(:)
252 character(len=*),
intent(in) :: fullfilename
253 character(50),
intent(inout) :: filename
254 character(3),
intent(inout) :: ext
255 character(1),
allocatable :: tempc(:)
256 character(len=30) :: tempcflex
259 lenc=len(adjustl(trim(fullfilename)))
260 if(.not.
allocated(tempc))
allocate(tempc(lenc))
261 tempcflex = adjustl(trim(fullfilename))
262 filename = adjustl(trim(tempcflex(1:lenc-4)))
263 ext = adjustl(trim(tempcflex(lenc-2:lenc+1)))
275 character(1) :: onechar
276 character(10) :: dummyc(10)
277 character(2) :: possiblenewsymbol, twochar
278 character(2),
allocatable :: sptempsymbols(:)
279 character(3),
optional,
intent(in) :: extin
280 character(3) :: extension
281 character(30) :: dummy
282 character(50) :: io_name, nametmp
283 character(60) :: pdbformat
284 character(len=*) :: filename
285 integer :: dummyi(10), header_lines, i, io_unit
286 integer :: ios, itemp, j, lines_to_lattice
287 integer :: max_lines, nats, nsp, verbose
288 integer :: lines_to_masses, lines_to_atom
290 real(
dp) :: abc_angles(2,3), dummyr(10), lbx1
291 real(
dp) :: lbx2, lby1, lby2, lbz1
292 real(
dp) :: lbz2, max_x, max_y, max_z
293 real(
dp) :: min_x, min_y, min_z, scfactor
299 max_x = 0.0_dp; max_y = 0.0_dp; max_z = 0.0_dp;
300 min_x = 0.0_dp; min_y = 0.0_dp; min_z = 0.0_dp;
302 if(
allocated(system%symbol)) stop
"ERROR: System already allocated"
304 if(.not.
present(extin))
then
308 nametmp = trim(adjustl(filename))
311 select case(extension)
316 io_name=trim(adjustl(nametmp))//
".xyz"
321 allocate(system%symbol(nats))
322 allocate(system%atomic_number(nats))
323 allocate(system%coordinate(3,nats))
324 allocate(system%mass(nats))
325 allocate(system%lattice_vector(3,3))
327 system%lattice_vector = 0.0_dp
330 read(io_unit,*)system%symbol(i),system%coordinate(1,i),system%coordinate(2,i),system%coordinate(3,i)
333 max_x = max(max_x,system%coordinate(1,i))
334 min_x = min(min_x,system%coordinate(1,i))
335 max_y = max(max_y,system%coordinate(2,i))
336 min_y = min(min_y,system%coordinate(2,i))
337 max_z = max(max_z,system%coordinate(3,i))
338 min_z = min(min_z,system%coordinate(3,i))
344 read(io_unit,*,iostat=ios)dummy
345 if(dummy.eq.
"#lattice")
then
346 if(verbose.eq.1)
write(*,*)
"There is a lattice ..."
347 read(io_unit,*)system%lattice_vector(1,1),system%lattice_vector(1,2),system%lattice_vector(1,3)
348 read(io_unit,*)system%lattice_vector(2,1),system%lattice_vector(2,2),system%lattice_vector(2,3)
349 read(io_unit,*)system%lattice_vector(3,1),system%lattice_vector(3,2),system%lattice_vector(3,3)
353 system%lattice_vector = 0.0_dp
354 system%lattice_vector(1,1) = max_x - min_x + 10.0_dp
355 system%lattice_vector(2,2) = max_y - min_y + 10.0_dp
356 system%lattice_vector(3,3) = max_z - min_z + 10.0_dp
364 io_name=trim(adjustl(nametmp))//
".pdb"
373 if(dummy.eq.
"ATOM".or.dummy.eq.
"HETATM")
then
376 header_lines = header_lines + 1
377 if(dummy.eq.
"CRYST1")
then
378 lines_to_lattice = header_lines
387 if(dummy.eq.
"ATOM".or.dummy.eq.
"HETATM")
then
397 if(i.eq.lines_to_lattice)
then
398 read(io_unit,*)dummy,abc_angles(1,1),abc_angles(1,2),abc_angles(1,3)&
399 ,abc_angles(2,1),abc_angles(2,2),abc_angles(2,3)
406 allocate(system%symbol(nats))
407 allocate(system%atomic_number(nats))
408 allocate(system%coordinate(3,nats))
409 allocate(system%mass(nats))
410 allocate(system%lattice_vector(3,3))
411 allocate(system%resname(nats))
412 allocate(system%resindex(nats))
413 allocate(system%atomname(nats))
415 system%lattice_vector = 0.0_dp
417 pdbformat=
'(A6,I5,1X,A4,A1,A3,1X,A1,I4,A1,3X,3F8.3,2F6.2,10X,A2,A2)'
420 read(io_unit,pdbformat)dummyc(1),dummyi(1), &
421 system%atomname(i),dummyc(3),system%resname(i),dummyc(4),system%resindex(i),dummyc(5),&
422 system%coordinate(1,i),system%coordinate(2,i),system%coordinate(3,i),&
423 dummyr(1),dummyr(2),system%symbol(i),dummyc(10)
426 if(dummyc(4).ne.
"".and.system%symbol(i).eq.
"")
then
427 onechar=adjustl(trim(dummyc(4)))
428 if(onechar.ne.
"H".and. &
429 onechar.ne.
"B".and. &
430 onechar.ne.
"C".and. &
431 onechar.ne.
"N".and. &
432 onechar.ne.
"O".and. &
433 onechar.ne.
"F".and. &
434 onechar.ne.
"P".and. &
435 onechar.ne.
"S".and. &
437 twochar=adjustl(trim(dummyc(4)))
438 system%symbol(i)=twochar
440 system%symbol(i)=onechar
452 max_x = max(max_x,system%coordinate(1,i))
453 min_x = min(min_x,system%coordinate(1,i))
454 max_y = max(max_y,system%coordinate(2,i))
455 min_y = min(min_y,system%coordinate(2,i))
456 max_z = max(max_z,system%coordinate(3,i))
457 min_z = min(min_z,system%coordinate(3,i))
466 system%lattice_vector = 0.0_dp
467 system%lattice_vector(1,1) = max_x - min_x + 10.0_dp
468 system%lattice_vector(2,2) = max_y - min_y + 10.0_dp
469 system%lattice_vector(3,3) = max_z - min_z + 10.0_dp
477 io_name=trim(adjustl(nametmp))//
".ltt"
479 read(io_unit,*)dummy, nats
480 read(io_unit,*)scfactor
482 allocate(system%symbol(nats))
483 allocate(system%atomic_number(nats))
484 allocate(system%coordinate(3,nats))
485 allocate(system%mass(nats))
486 allocate(system%lattice_vector(3,3))
489 read(io_unit,*)lbx1,lbx2,lby1,lby2,lbz1,lbz2
490 system%lattice_vector = 0.0_dp
491 system%lattice_vector(1,1) = (lbx2-lbx1)*scfactor
492 system%lattice_vector(2,2) = (lby2-lby1)*scfactor
493 system%lattice_vector(3,3) = (lbz2-lbz1)*scfactor
496 read(io_unit,*)system%symbol(i),system%coordinate(1,i)&
497 ,system%coordinate(2,i),system%coordinate(3,i)
498 system%coordinate(1,i)= system%coordinate(1,i)*scfactor
499 system%coordinate(2,i)= system%coordinate(2,i)*scfactor
500 system%coordinate(3,i)= system%coordinate(3,i)*scfactor
510 io_name=trim(adjustl(nametmp))//
".dat"
514 allocate(system%symbol(nats))
515 allocate(system%atomic_number(nats))
516 allocate(system%coordinate(3,nats))
517 allocate(system%mass(nats))
518 allocate(system%lattice_vector(3,3))
521 system%lattice_vector = 0.0_dp
522 read(io_unit,*)system%lattice_vector(1,1),system%lattice_vector(1,2),system%lattice_vector(1,3)
523 read(io_unit,*)system%lattice_vector(2,1),system%lattice_vector(2,2),system%lattice_vector(2,3)
524 read(io_unit,*)system%lattice_vector(3,1),system%lattice_vector(3,2),system%lattice_vector(3,3)
527 read(io_unit,*)system%symbol(i),system%coordinate(1,i)&
528 ,system%coordinate(2,i),system%coordinate(3,i)
529 system%coordinate(1,i)= system%coordinate(1,i)
530 system%coordinate(2,i)= system%coordinate(2,i)
531 system%coordinate(3,i)= system%coordinate(3,i)
540 stop
"gen format is not implemented for reading yet"
546 io_name=adjustl(trim(nametmp))//
".lmp"
548 read(io_unit,*)dummyc(1)
549 read(io_unit,*)system%nats
552 read(io_unit,*)dummyc(1),dummyc(2)
554 if(adjustl(trim(dummyc(2))) ==
"atom")
then
555 lines_to_atom = i + 2
557 if(adjustl(trim(dummyc(1))) ==
"Masses")
then
558 lines_to_masses = i + 2
566 do i=1,lines_to_atom-1
567 read(io_unit,*)dummyc(1)
570 read(io_unit,*)system%nsp
572 do i=1,lines_to_masses - lines_to_atom - 4
573 read(io_unit,*)dummyc(1)
576 read(io_unit,*)min_x, max_x
577 read(io_unit,*)min_y, max_y
578 read(io_unit,*)min_z, max_z
580 allocate(system%lattice_vector(3,3))
581 system%lattice_vector = 0.0_dp
582 system%lattice_vector(1,1) = max_x - min_x
583 system%lattice_vector(2,2) = max_y - min_y
584 system%lattice_vector(3,3) = max_z - min_z
586 read(io_unit,*)dummyc(1)
588 allocate(system%spmass(system%nsp))
589 allocate(system%splist(system%nsp))
592 read(io_unit,*)dummyi(1),system%spmass(i)
605 read(io_unit,*)dummyc(1)
606 if(dummyc(1) ==
"Atoms")
exit
609 allocate(system%spindex(system%nats))
610 allocate(system%coordinate(3,system%nats))
611 allocate(system%symbol(system%nats))
614 read(io_unit,*)dummyi(1),dummyi(2),system%spindex(i),dummyr(1),system%coordinate(1,i)&
615 ,system%coordinate(2,i),system%coordinate(3,i)
616 write(*,*)dummyi(1),dummyi(2),system%spindex(i),dummyr(1),system%coordinate(1,i)&
617 ,system%coordinate(2,i),system%coordinate(3,i)
618 system%symbol(i) = system%splist(system%spindex(i))
625 stop
"The file extension is not valid. Only xyz, lmp, dat and pdb formats are implemented"
632 allocate(sptempsymbols(150))
633 sptempsymbols(1)=system%Symbol(1)
635 if(.not.
allocated(system%spindex))
allocate(system%spindex(nats))
640 if(trim(system%symbol(i)).ne.trim(sptempsymbols(j)))
then
642 possiblenewsymbol = system%symbol(i)
647 sptempsymbols(nsp)=possiblenewsymbol
651 if(
allocated(system%splist))
deallocate(system%splist)
652 if(
allocated(system%spmass))
deallocate(system%spmass)
654 allocate(system%splist(nsp))
655 allocate(system%spmass(nsp))
656 allocate(system%spatnum(nsp))
659 system%splist(i) = sptempsymbols(i)
664 deallocate(sptempsymbols)
671 if(trim(system%symbol(i)).eq.trim(system%splist(j)))
then
688 if(
allocated(sy%symbol))
deallocate(sy%symbol)
689 if(
allocated(sy%atomic_number))
deallocate(sy%atomic_number)
690 if(
allocated(sy%coordinate))
deallocate(sy%coordinate)
691 if(
allocated(sy%velocity))
deallocate(sy%velocity)
692 if(
allocated(sy%force))
deallocate(sy%force)
693 if(
allocated(sy%net_charge))
deallocate(sy%net_charge)
694 if(
allocated(sy%mass))
deallocate(sy%mass)
695 if(
allocated(sy%lattice_vector))
deallocate(sy%lattice_vector)
696 if(
allocated(sy%recip_vector))
deallocate(sy%recip_vector)
697 if(
allocated(sy%spindex))
deallocate(sy%spindex)
698 if(
allocated(sy%splist))
deallocate(sy%splist)
699 if(
allocated(sy%spatnum))
deallocate(sy%spatnum)
700 if(
allocated(sy%spmass))
deallocate(sy%spmass)
701 if(
allocated(sy%userdef))
deallocate(sy%userdef)
702 if(
allocated(sy%resindex))
deallocate(sy%resindex)
703 if(
allocated(sy%resname))
deallocate(sy%resname)
704 if(
allocated(sy%atomname))
deallocate(sy%atomname)
715 if(
allocated(estr%hindex))
deallocate(estr%hindex)
716 if(bml_allocated(estr%ham))
call bml_deallocate(estr%ham)
717 if(bml_allocated(estr%hamAux))
call bml_deallocate(estr%hamAux)
718 if(bml_allocated(estr%ham0))
call bml_deallocate(estr%ham0)
719 if(bml_allocated(estr%oham))
call bml_deallocate(estr%oham)
720 if(bml_allocated(estr%ohamAux))
call bml_deallocate(estr%ohamAux)
721 if(bml_allocated(estr%over))
call bml_deallocate(estr%over)
722 if(bml_allocated(estr%rho))
call bml_deallocate(estr%rho)
723 if(bml_allocated(estr%evects))
call bml_deallocate(estr%evects)
724 if(bml_allocated(estr%matAux))
call bml_deallocate(estr%matAux)
725 if(bml_allocated(estr%zmat))
call bml_deallocate(estr%zmat)
726 if(
allocated(estr%coul_pot_r))
deallocate(estr%coul_pot_r)
727 if(
allocated(estr%coul_pot_k))
deallocate(estr%coul_pot_k)
728 if(
allocated(estr%skforce))
deallocate(estr%skforce)
729 if(
allocated(estr%fpul))
deallocate(estr%fpul)
730 if(
allocated(estr%fscoul))
deallocate(estr%fscoul)
731 if(
allocated(estr%aux))
deallocate(estr%aux)
732 if(
allocated(estr%evals))
deallocate(estr%evals)
733 if(
allocated(estr%dvals))
deallocate(estr%dvals)
734 if(
allocated(estr%ker))
deallocate(estr%ker)
746 character(len=*) :: filename
747 character(10) :: dummyc(10)
748 character(34) :: xyzformat
749 character(3),
optional,
intent(in) :: extin
750 character(3) :: extension
751 character(50) :: io_name, nametmp
752 character(60) :: pdbformat
753 character(100) :: io_message
754 integer :: dummyi(10), i, io_unit, nats
755 real(
dp) :: abc_angles(2,3), dummyr(10), origin(3)
760 if(.not.
present(extin))
then
764 nametmp = trim(filename)
767 select case(extension)
771 io_name=trim(nametmp)//
".xyz"
774 io_message = trim(adjustl(io_name))//
" Generated by the PROGRESS library"
775 write(io_unit,*)trim(adjustl(io_message))
776 xyzformat =
'(A2,A2,1F10.5,A2,1F10.5,A2,1F10.5)'
778 write(io_unit,xyzformat)system%symbol(i),
" ",system%coordinate(1,i),
" ",system%coordinate(2,i),
" ",system%coordinate(3,i)
783 write(io_unit,*)
"#lattice vectors"
784 write(io_unit,
"(3F20.5)")system%lattice_vector(1,1),system%lattice_vector(1,2),system%lattice_vector(1,3)
785 write(io_unit,
"(3F20.5)")system%lattice_vector(2,1),system%lattice_vector(2,2),system%lattice_vector(2,3)
786 write(io_unit,
"(3F20.5)")system%lattice_vector(3,1),system%lattice_vector(3,2),system%lattice_vector(3,3)
797 io_name=trim(nametmp)//
".pdb"
800 write(io_unit,
'(A6,1X,A50)')
"REMARK",
"Generated by PROGRESS library"
801 write(io_unit,
'(A5,1X,A20)')
"TITLE",io_name
803 if(
allocated(system%lattice_vector))
then
805 write(io_unit,
'(A6,3F9.3,3F7.2,A16)')
"CRYST1",abc_angles(1,1),abc_angles(1,2),abc_angles(1,3)&
806 ,abc_angles(2,1),abc_angles(2,2),abc_angles(2,3),
" P 1 1"
809 write(io_unit,
'(A5,A20)')
"MODEL",
" 1"
811 pdbformat=
'(A4,A2,I5,1X,A4,A1,A3,1X,A1,I4,A1,3X,3F8.3,2F6.2,10X,A2,A2 )'
813 if(.not.
allocated(system%resindex))
then
814 allocate(system%resindex(nats))
818 if(.not.
allocated(system%resname))
then
819 allocate(system%resname(nats))
820 system%resname =
"MOL"
823 if(.not.
allocated(system%atomname))
then
824 allocate(system%atomname(nats))
825 system%atomname = system%symbol
828 if(
allocated(system%net_charge))
then
830 write(io_unit,pdbformat)dummyc(1),dummyc(2),i, &
831 system%atomname(i),dummyc(5),system%resname(i),dummyc(7),system%resindex(i),dummyc(8),&
832 system%coordinate(1,i),system%coordinate(2,i),system%coordinate(3,i),&
833 dummyr(1),system%net_charge(i),system%symbol(i),dummyc(10)
837 write(io_unit,pdbformat)dummyc(1),dummyc(2),i, &
838 system%atomname(i),dummyc(5),system%resname(i),dummyc(7),system%resindex(i),dummyc(8),&
839 system%coordinate(1,i),system%coordinate(2,i),system%coordinate(3,i),&
840 dummyr(1),dummyr(2),system%symbol(i),dummyc(10)
844 write(io_unit,
'(A3)')
"TER"
845 write(io_unit,
'(A3)')
"ENDMDL"
852 io_name=trim(nametmp)//
".ltt"
854 write(io_unit,*)
"NATS= ", system%nats
857 write(io_unit,*)
"1.0",
" Generated by the PROGRESS library"
860 write(io_unit,
"(6F10.5)")0.0,system%lattice_vector(1,1),0.0,system%lattice_vector(2,2)&
861 ,0.0,system%lattice_vector(3,3)
864 write(io_unit,
"(A2,3F10.5)")system%symbol(i),system%coordinate(1,i)&
865 ,system%coordinate(2,i),system%coordinate(3,i)
873 io_name=trim(nametmp)//
".dat"
875 write(io_unit,*)system%nats
878 write(io_unit,
"(3F10.5)")system%lattice_vector(1,1),system%lattice_vector(1,2),system%lattice_vector(1,3)
879 write(io_unit,
"(3F10.5)")system%lattice_vector(2,1),system%lattice_vector(2,2),system%lattice_vector(2,3)
880 write(io_unit,
"(3F10.5)")system%lattice_vector(3,1),system%lattice_vector(3,2),system%lattice_vector(3,3)
883 write(io_unit,
"(A2,3F10.5)")system%symbol(i),system%coordinate(1,i)&
884 ,system%coordinate(2,i),system%coordinate(3,i)
892 io_name=trim(nametmp)//
".gen"
894 write(io_unit,*)system%nats,
"S"
895 write(io_unit,
'(103A3)')(system%splist(i),i=1,system%nsp)
897 write(io_unit,
"(I10,I10,3F10.5)")i,system%spindex(i),system%coordinate(1,i)&
898 ,system%coordinate(2,i),system%coordinate(3,i)
900 write(io_unit,*)
"0.0 0.0 0.0"
901 write(io_unit,
'(3F10.5)')system%lattice_vector(1,1),system%lattice_vector(1,2),system%lattice_vector(1,3)
902 write(io_unit,
'(3F10.5)')system%lattice_vector(2,1),system%lattice_vector(2,2),system%lattice_vector(2,3)
903 write(io_unit,
'(3F10.5)')system%lattice_vector(3,1),system%lattice_vector(3,2),system%lattice_vector(3,3)
911 io_name= adjustl(trim(nametmp))//
".lmp"
913 write(io_unit,*)
"LAMMPS Description"
915 write(io_unit,*)system%nats,
"atoms"
917 write(io_unit,*)system%nsp,
"atom types"
919 write(io_unit,*)0.0_dp,system%lattice_vector(1,1),
"xlo xhi"
920 write(io_unit,*)0.0_dp,system%lattice_vector(2,2),
"ylo yhi"
921 write(io_unit,*)0.0_dp,system%lattice_vector(3,3),
"zlo zhi"
922 write(io_unit,*)system%lattice_vector(2,1),system%lattice_vector(3,1), &
923 &system%lattice_vector(3,2),
"xy xz yz"
926 write(io_unit,*)
"Masses"
929 write(io_unit,*)
" ",i,system%spmass(i)
932 write(io_unit,*)
"Atoms"
935 write(io_unit,
'(3I5,A6,3F10.5)')i,1,system%spindex(i),
" 0.0",system%coordinate(1,i)&
936 ,system%coordinate(2,i),system%coordinate(3,i)
943 stop
"The file extension is not valid. Only xyz, dat, lmp, pdb or gen formats are implemented"
958 character(len=*) :: filename
959 character(10) :: dummyc(10)
960 character(11) :: xyzformat
961 character(20) :: io_name
962 character(3) :: extension
963 character(60) :: pdbformat
964 integer :: dummyi(10), i, io_unit, nats
965 integer,
intent(in) :: iter, each
966 integer,
allocatable :: resindex(:)
967 real(
dp) :: abc_angles(2,3), dummyr(10)
968 real(
dp),
intent(in) :: prg_deltat
971 if(mod(iter,each).eq.0.or.iter.eq.0.or.iter.eq.1)
then
974 select case(extension)
978 io_name=trim(filename)//
".xyz"
981 if(iter.eq.0.or.iter.eq.1)
then
982 open(unit=io_unit,file=io_name,status=
'unknown')
984 open(unit=io_unit,file=io_name,position =
'append',status=
'old')
987 write(io_unit,*)system%nats
988 write(io_unit,*)
"frame", iter
989 if(
allocated(system%net_charge))
then
991 write(io_unit,
"(A3,3X,F20.15,3X,F20.15,3X,F20.15,3X,F20.15)")system%symbol(i),system%coordinate(1,i),&
992 system%coordinate(2,i),system%coordinate(3,i),system%net_charge(i)
996 write(io_unit,
"(A3,3X,F20.15,3X,F20.15,3X,F20.15)")system%symbol(i),system%coordinate(1,i),&
997 system%coordinate(2,i),system%coordinate(3,i)
1012 io_name=trim(filename)//
".pdb"
1015 if(iter.eq.0.or.iter.eq.1)
then
1016 open(unit=io_unit,file=io_name,status=
'unknown')
1018 open(unit=io_unit,file=io_name,position =
'append',status=
'old')
1021 write(io_unit,
'(A17,A4,F10.5)')
"REMARK Trajectory",
" t=",iter*prg_deltat
1022 write(io_unit,
'(A31)')
"REMARK THIS IS A SIMULATION BOX"
1023 write(io_unit,
'(A6,3F9.3,3F7.2,A16)')
"CRYST1",abc_angles(1,1),abc_angles(1,2),abc_angles(1,3)&
1024 ,abc_angles(2,1),abc_angles(2,2),abc_angles(2,3),
" P 1 1"
1025 write(io_unit,
'(A5,I6)')
"MODEL",iter
1027 pdbformat=
'(A4,A2,I5,1X,A4,A1,A3,1X,A1,I4,A1,3X,3F8.3,2F6.2,11X,A2,A2 )'
1029 if(.not.
allocated(system%resindex))
then
1030 allocate(resindex(nats))
1033 resindex = system%resindex
1037 if(
allocated(system%net_charge))
then
1039 write(io_unit,pdbformat)dummyc(1),dummyc(2),i, &
1040 system%symbol(i),dummyc(5),
"MOL",dummyc(7),resindex(i),dummyc(8),&
1041 system%coordinate(1,i),system%coordinate(2,i),system%coordinate(3,i),&
1042 dummyr(1),system%net_charge(i),system%symbol(i),dummyc(10)
1046 write(io_unit,pdbformat)dummyc(1),dummyc(2),i, &
1047 system%symbol(i),dummyc(5),
"MOL",dummyc(7),resindex(i),dummyc(8),&
1048 system%coordinate(1,i),system%coordinate(2,i),system%coordinate(3,i),&
1049 dummyr(1),dummyr(2),system%symbol(i),dummyc(10)
1053 write(io_unit,
'(A3)')
"TER"
1054 write(io_unit,
'(A6)')
"ENDMDL"
1059 write(*,*)
"write traj not implemented for dat "
1063 stop
"The file extension is not valid. Only pdb and xyz formats are implemented"
1082 character(len=*) :: filename
1083 character(10) :: dummyc(10)
1084 character(11) :: xyzformat
1085 character(20) :: io_name
1086 character(3) :: extension
1087 character(60) :: pdbformat
1088 integer :: dummyi(10), i, io_unit, nats
1089 integer,
intent(in) :: iter, each
1090 integer,
allocatable :: resindex(:)
1091 real(
dp) :: abc_angles(2,3), dummyr(10)
1092 real(
dp) :: maxprop, minprop, realtmp
1093 real(
dp),
intent(in) :: prg_deltat, scalarprop(:)
1100 if(mod(iter,each).eq.0.or.iter.eq.0.or.iter.eq.1)
then
1103 select case(extension)
1114 io_name=trim(filename)//
".pdb"
1117 if(iter.eq.0.or.iter.eq.1)
then
1118 open(unit=io_unit,file=io_name,status=
'unknown')
1120 open(unit=io_unit,file=io_name,position =
'append',status=
'old')
1123 write(io_unit,
'(A8,A4,F10.5)')
"Trajectory",
" t=",iter*prg_deltat
1124 write(io_unit,
'(A24)')
"THIS IS A SIMULATION BOX"
1125 write(io_unit,
'(A6,3F9.3,3F7.2,A16)')
"CRYST1",abc_angles(1,1),abc_angles(1,2),abc_angles(1,3)&
1126 ,abc_angles(2,1),abc_angles(2,2),abc_angles(2,3),
" P 1 1"
1127 write(io_unit,
'(A5,I6)')
"MODEL",iter
1129 pdbformat=
'(A4,A2,I5,1X,A4,A1,A3,1X,A1,I4,A1,3X,3F8.3,2F6.2,10X,A2,A2 )'
1131 if(.not.
allocated(system%resindex))
then
1132 allocate(resindex(nats))
1135 resindex = system%resindex
1140 write(io_unit,pdbformat)dummyc(1),dummyc(2),i, &
1141 system%symbol(i),dummyc(5),
"MOL",dummyc(7),resindex(i),dummyc(8),&
1142 system%coordinate(1,i),system%coordinate(2,i),system%coordinate(3,i),&
1143 dummyr(1),scalarprop(i),system%symbol(i),dummyc(10)
1146 write(io_unit,
'(A3)')
"TER"
1147 write(io_unit,
'(A3)')
"ENDMDL"
1152 io_name=trim(filename)//
".xyz"
1155 if(iter.eq.0.or.iter.eq.1)
then
1156 open(unit=io_unit,file=io_name,status=
'unknown')
1158 open(unit=io_unit,file=io_name,position =
'append',status=
'old')
1161 write(io_unit,*)system%nats
1162 write(io_unit,*)
"frame", iter
1165 write(io_unit,*)system%symbol(i),system%coordinate(1,i),system%coordinate(2,i),system%coordinate(3,i),&
1174 stop
"The file extension is not valid. Only pdb format is implemented"
1193 integer :: i, nats, seed
1194 real(
dp) :: lx, ly, lz, ran
1199 allocate(system%symbol(nats))
1200 allocate(system%atomic_number(nats))
1201 allocate(system%coordinate(3,nats))
1202 allocate(system%mass(nats))
1204 call random_seed(seed)
1208 system%atomic_number(i) = 1
1209 call random_number(ran)
1210 system%coordinate(i,1) = ran*lx
1211 call random_number(ran)
1212 system%coordinate(i,2) = ran*ly
1213 call random_number(ran)
1214 system%coordinate(i,3) = ran*lz
1221 allocate(system%lattice_vector(3,3))
1222 system%lattice_vector = 0.0_dp
1223 system%lattice_vector(1,1) = lx
1224 system%lattice_vector(2,2) = ly
1225 system%lattice_vector(3,3) = lz
1238 real(
dp) :: angle_alpha, angle_beta, angle_gamma, lattice_a
1239 real(
dp) :: lattice_b, lattice_c, pi
1240 real(
dp),
intent(in) :: abc_angles(2,3)
1241 real(
dp),
intent(out) :: lattice_vector(3,3)
1243 pi = 3.14159265358979323846264338327950_dp
1245 lattice_a = abc_angles(1,1)
1246 lattice_b = abc_angles(1,2)
1247 lattice_c = abc_angles(1,3)
1248 angle_alpha = abc_angles(2,1)
1249 angle_beta = abc_angles(2,2)
1250 angle_gamma = abc_angles(2,3)
1252 angle_alpha = 2.0_dp*pi*angle_alpha/360.0_dp
1253 angle_beta = 2.0_dp*pi*angle_beta/360.0_dp
1254 angle_gamma = 2.0_dp*pi*angle_gamma/360.0_dp
1256 lattice_vector(1,1) = lattice_a
1257 lattice_vector(1,2)=0
1258 lattice_vector(1,3)=0
1260 lattice_vector(2,1)=lattice_b*cos(angle_gamma)
1261 lattice_vector(2,2)=lattice_b*sin(angle_gamma)
1262 lattice_vector(2,3)=0
1264 lattice_vector(3,1)=lattice_c*cos(angle_beta)
1265 lattice_vector(3,2)=lattice_c*( cos(angle_alpha)-cos(angle_gamma)* &
1266 cos(angle_beta) )/sin(angle_gamma)
1267 lattice_vector(3,3)=sqrt(lattice_c**2 - lattice_vector(3,1)**2 - lattice_vector(3,2)**2)
1280 real(
dp) :: angle_alpha, angle_beta, angle_gamma, lattice_a
1281 real(
dp) :: lattice_b, lattice_c, pi
1282 real(
dp),
intent(in) :: lattice_vector(3,3)
1283 real(
dp),
intent(out) :: abc_angles(2,3)
1285 pi = 3.14159265358979323846264338327950_dp
1287 lattice_a = sqrt(lattice_vector(1,1)**2+lattice_vector(1,2)**2+lattice_vector(1,3)**2)
1288 lattice_b = sqrt(lattice_vector(2,1)**2+lattice_vector(2,2)**2+lattice_vector(2,3)**2)
1289 lattice_c = sqrt(lattice_vector(3,1)**2+lattice_vector(3,2)**2+lattice_vector(3,3)**2)
1291 angle_gamma = dot_product(lattice_vector(1,:),lattice_vector(2,:))/(lattice_a*lattice_b)
1292 angle_beta = dot_product(lattice_vector(1,:),lattice_vector(3,:))/(lattice_a*lattice_c)
1293 angle_alpha = dot_product(lattice_vector(2,:),lattice_vector(3,:))/(lattice_b*lattice_c)
1296 angle_alpha = 360.0_dp*acos(angle_alpha)/(2.0_dp*pi)
1297 angle_beta = 360.0_dp*acos(angle_beta)/(2.0_dp*pi)
1298 angle_gamma = 360.0_dp*acos(angle_gamma)/(2.0_dp*pi)
1300 abc_angles(1,1) = lattice_a
1301 abc_angles(1,2) = lattice_b
1302 abc_angles(1,3) = lattice_c
1304 abc_angles(2,1) = angle_alpha
1305 abc_angles(2,2) = angle_beta
1306 abc_angles(2,3) = angle_gamma
1317 real(
dp) :: max_x, max_y, max_z, min_x
1318 real(
dp) :: min_y, min_z
1319 real(
dp),
allocatable,
intent(inout) :: origin(:)
1320 real(
dp),
intent(in) :: coords(:,:)
1322 if(.not.
allocated(origin))
allocate(origin(3))
1324 max_x = -1.0d5 ; max_y = -1.0d5 ; max_z = -1.0d5 ;
1325 min_x = 1.0d5 ; min_y = 1.0d5 ; min_z = 1.0d5 ;
1328 do i=1,
size(coords,dim=2)
1329 max_x = max(max_x,coords(1,i))
1330 min_x = min(min_x,coords(1,i))
1331 max_y = max(max_y,coords(2,i))
1332 min_y = min(min_y,coords(2,i))
1333 max_z = max(max_z,coords(3,i))
1334 min_z = min(min_z,coords(3,i))
1351 real(
dp),
intent(in) :: coords(:,:)
1352 real(
dp),
intent(out),
allocatable :: dmat(:,:)
1354 nats =
size(coords,dim=2)
1355 if(.not.
allocated(dmat))
allocate(dmat(nats,nats))
1360 dmat(i,j) =
prg_norm2(coords(:,i)-coords(:,j))
1375 integer,
intent(in),
optional :: verbose
1376 real(
dp) :: max_x, max_y, max_z, min_x
1377 real(
dp) :: min_y, min_z
1378 real(
dp),
allocatable,
intent(inout) :: origin(:),coords(:,:)
1379 real(
dp),
intent(in) :: lattice_vectors(:,:)
1381 if(
present(verbose))
then
1382 if(verbose >= 1)
write(*,*)
"In prg_translateandfoldtobox ..."
1385 max_x = -1.0d5 ; max_y = -1.0d5 ; max_z = -1.0d5 ;
1386 min_x = 1.0d5 ; min_y = 1.0d5 ; min_z = 1.0d5 ;
1389 do i=1,
size(coords,dim=2)
1390 max_x = max(max_x,coords(1,i))
1391 min_x = min(min_x,coords(1,i))
1392 max_y = max(max_y,coords(2,i))
1393 min_y = min(min_y,coords(2,i))
1394 max_z = max(max_z,coords(3,i))
1395 min_z = min(min_z,coords(3,i))
1398 if(.not.
allocated(origin))
then
1405 coords(1,:) = coords(1,:) - origin(1)
1406 coords(2,:) = coords(2,:) - origin(2)
1407 coords(3,:) = coords(3,:) - origin(3)
1409 coords(1,:) = mod(coords(1,:)*1000000,1000000*lattice_vectors(1,1))/1000000;
1410 coords(2,:) = mod(coords(2,:)*1000000,1000000*lattice_vectors(2,2))/1000000;
1411 coords(3,:) = mod(coords(3,:)*1000000,1000000*lattice_vectors(3,3))/1000000;
1416 origin(1) = -1.0d-1 ; origin(2) = -1.0d-1; origin(3) = -1.0d-1
1429 integer,
intent(in),
optional :: verbose
1431 real(
dp),
allocatable,
intent(inout) :: coords(:,:)
1432 real(
dp),
intent(in) :: lattice_vectors(:,:)
1434 if(
present(verbose))
then
1435 if(verbose >= 1)
write(*,*)
"In prg_centeratbox ..."
1438 nats=
size(coords,dim=2)
1455 coords(1,i) = coords(1,i) + lattice_vectors(1,1)/2.0d0 - gc(1)
1456 coords(2,i) = coords(2,i) + lattice_vectors(2,2)/2.0d0 - gc(2)
1457 coords(3,i) = coords(3,i) + lattice_vectors(3,3)/2.0d0 - gc(3)
1471 integer,
intent(in) :: index
1472 integer,
intent(in),
optional :: verbose
1473 real(
dp),
allocatable,
intent(inout) :: coords(:,:)
1474 real(
dp),
allocatable :: origin(:)
1475 real(
dp),
intent(in) :: lattice_vectors(:,:)
1477 if(
present(verbose))
then
1478 if(verbose >= 1)
write(*,*)
"In prg_wraparound ..."
1481 if(.not.
allocated(origin))
allocate(origin(3))
1483 nats=
size(coords,dim=2)
1485 origin(1) = -coords(1,index) + lattice_vectors(1,1)/2.0_dp
1486 origin(2) = -coords(2,index) + lattice_vectors(2,2)/2.0_dp
1487 origin(3) = -coords(3,index) + lattice_vectors(3,3)/2.0_dp
1489 coords(1,:) = coords(1,:) + origin(1)
1490 coords(2,:) = coords(2,:) + origin(2)
1491 coords(3,:) = coords(3,:) + origin(3)
1496 if(coords(1,i) > lattice_vectors(1,1))coords(1,i)=coords(1,i)-lattice_vectors(1,1)
1497 if(coords(2,i) > lattice_vectors(2,2))coords(2,i)=coords(2,i)-lattice_vectors(2,2)
1498 if(coords(3,i) > lattice_vectors(3,3))coords(3,i)=coords(3,i)-lattice_vectors(3,3)
1499 if(coords(1,i) < 0.0_dp)coords(1,i)=coords(1,i)+lattice_vectors(1,1)
1500 if(coords(2,i) < 0.0_dp)coords(2,i)=coords(2,i)+lattice_vectors(2,2)
1501 if(coords(3,i) < 0.0_dp)coords(3,i)=coords(3,i)+lattice_vectors(3,3)
1516 real(
dp),
allocatable,
intent(inout) :: origin(:),coords(:,:)
1517 real(
dp),
intent(in) :: lattice_vectors(:,:)
1518 real(
dp) :: geomc(3)
1520 if(.not.
allocated(origin))
allocate(origin(3))
1523 do i=1,
size(coords,dim=2)
1524 geomc = geomc + coords(:,i)
1527 geomc = geomc/
size(coords,dim=2)
1529 coords(1,:) = coords(1,:) - geomc(1)
1530 coords(2,:) = coords(2,:) - geomc(2)
1531 coords(3,:) = coords(3,:) - geomc(3)
1533 coords(1,:) = mod(coords(1,:)*1000000,1000000*lattice_vectors(1,1))/1000000;
1534 coords(2,:) = mod(coords(2,:)*1000000,1000000*lattice_vectors(2,2))/1000000;
1535 coords(3,:) = mod(coords(3,:)*1000000,1000000*lattice_vectors(3,3))/1000000;
1540 origin(1) = -1.0d-1 ; origin(2) = -1.0d-1; origin(3) = -1.0d-1
1554 integer :: i, j, k, l
1555 integer :: m, fnats, nats
1556 integer,
intent(in) :: nx, ny,
nz
1557 character(2),
allocatable,
intent(inout) :: symbols(:)
1558 character(2),
allocatable :: rsymbols(:)
1559 real(
dp),
allocatable,
intent(inout) :: coords(:,:)
1560 real(
dp),
intent(inout) :: lattice_vectors(:,:)
1561 real(
dp),
allocatable :: r(:,:)
1563 nats =
size(coords,dim=2)
1564 fnats = nx*ny*
nz*nats
1566 allocate(r(3,fnats))
1567 allocate(rsymbols(fnats))
1575 r(1,m)=i*lattice_vectors(1,1) + j*lattice_vectors(1,2) + k*lattice_vectors(1,3)
1576 r(1,m)=r(1,m) + coords(1,l)
1577 r(2,m)=i*lattice_vectors(2,1) + j*lattice_vectors(2,2) + k*lattice_vectors(2,3)
1578 r(2,m)=r(2,m) + coords(2,l)
1579 r(3,m)=i*lattice_vectors(3,1) + j*lattice_vectors(3,2) + k*lattice_vectors(3,3)
1580 r(3,m)=r(3,m) + coords(3,l)
1581 rsymbols(m) = symbols(l)
1587 deallocate(coords,symbols)
1588 allocate(coords(3,fnats))
1589 allocate(symbols(fnats))
1591 lattice_vectors(1,:) = nx*lattice_vectors(1,:)
1592 lattice_vectors(2,:) = ny*lattice_vectors(2,:)
1593 lattice_vectors(3,:) =
nz*lattice_vectors(3,:)
1597 deallocate(r,rsymbols)
1611 integer :: i, j, k, l
1612 integer :: ini, fin, cont, ii
1613 integer,
intent(in) :: nx, ny,
nz
1617 if(.not.
allocated(sy%coordinate))
then
1618 write(*,*)
"ERROR: System does not have coordinate"
1621 if(.not.
allocated(sy%symbol))
then
1622 write(*,*)
"ERROR: System does not have atomic symbols"
1625 syf%nats = sy%nats*nx*ny*
nz
1626 allocate(syf%coordinate(3,syf%nats))
1627 allocate(syf%symbol(syf%nats))
1628 allocate(syf%resindex(syf%nats))
1629 allocate(syf%atomname(syf%nats))
1630 allocate(syf%atomic_number(syf%nats))
1631 allocate(syf%spindex(syf%nats))
1639 syf%coordinate(1,cont) = sy%coordinate(1,ii) + &
1640 & sy%lattice_vector(1,1)*i + sy%lattice_vector(2,1)*i + sy%lattice_vector(3,1)*i
1641 syf%coordinate(2,cont) = sy%coordinate(2,ii) + &
1642 & sy%lattice_vector(1,2)*j + sy%lattice_vector(2,2)*j + sy%lattice_vector(3,2)*j
1643 syf%coordinate(3,cont) = sy%coordinate(3,ii) + &
1644 & sy%lattice_vector(1,3)*k + sy%lattice_vector(2,3)*k + sy%lattice_vector(3,3)*k
1645 syf%symbol(cont) = sy%symbol(ii)
1651 if(
allocated(sy%resindex))
then
1653 ini = (i - 1)*sy%nats + 1
1655 syf%resindex(ini:fin) = sy%resindex(:)
1661 if(
allocated(sy%atomname))
then
1663 ini = (i - 1)*sy%nats + 1
1665 syf%atomname(ini:fin) = sy%atomname(:)
1671 if(
allocated(sy%atomic_number))
then
1673 ini = (i - 1)*sy%nats + 1
1675 syf%atomic_number(ini:fin) = sy%atomic_number(:)
1678 if(
allocated(sy%spindex))
then
1680 ini = (i - 1)*sy%nats + 1
1682 syf%spindex(ini:fin) = sy%spindex(:)
1686 allocate(syf%lattice_vector(3,3))
1687 syf%lattice_vector(1,:) = nx*sy%lattice_vector(1,:)
1688 syf%lattice_vector(2,:) = ny*sy%lattice_vector(2,:)
1689 syf%lattice_vector(3,:) =
nz*sy%lattice_vector(3,:)
1691 if(
allocated(sy%splist))
then
1693 allocate(syf%splist(syf%nsp))
1694 syf%splist = sy%splist
1708 integer :: i, natstmp, l, count, j, count1
1709 integer,
intent(inout) :: nats
1710 integer,
intent(in),
optional :: verbose
1712 real(
dp),
allocatable,
intent(inout) :: coords(:,:)
1713 real(
dp),
allocatable :: coordstmp(:,:)
1714 character(len=*),
allocatable,
intent(inout) :: symbols(:)
1715 character(2),
allocatable :: symbolstmp(:)
1717 if(
present(verbose))
then
1718 if(verbose >= 1)
write(*,*)
"In prg_cleanuprepeatedatoms ..."
1723 allocate(coordstmp(3,nats))
1724 allocate(symbolstmp(nats))
1726 coordstmp(1,1)=coords(1,1)
1727 coordstmp(2,1)=coords(2,1)
1728 coordstmp(3,1)=coords(3,1)
1731 symbolstmp(1)=symbols(1)
1737 d=sqrt((coords(1,j)-coordstmp(1,i))**2+(coords(2,j)-coordstmp(2,i))**2+&
1738 &(coords(3,j)-coordstmp(3,i))**2)
1748 write(*,*)
"Problem at iteration",j
1753 coordstmp(1,l)=coords(1,j)
1754 coordstmp(2,l)=coords(2,j)
1755 coordstmp(3,l)=coords(3,j)
1756 symbolstmp(l)=symbols(j)
1763 allocate(symbols(nats))
1764 allocate(coords(3,nats))
1767 symbols(i) = symbolstmp(i)
1768 coords(:,i) = coordstmp(:,i)
1771 deallocate(coordstmp)
1772 deallocate(symbolstmp)
1789 real(
dp) :: a1xa2(3), a2xa3(3), a3xa1(3), b2xb3(3)
1791 real(
dp),
allocatable,
intent(inout) :: recip_vectors(:,:)
1792 real(
dp),
intent(in) :: lattice_vectors(:,:)
1793 real(
dp),
intent(inout) :: volk, volr
1795 if(.not.
allocated(recip_vectors))
allocate(recip_vectors(3,3))
1796 volr=0.0_dp; volk=0.0_dp
1798 pi = 3.14159265358979323846264338327950_dp
1800 a1xa2(1) = lattice_vectors(1,2)*lattice_vectors(2,3) - lattice_vectors(1,3)*lattice_vectors(2,2)
1801 a1xa2(2) = -lattice_vectors(1,1)*lattice_vectors(2,3) + lattice_vectors(1,3)*lattice_vectors(2,1)
1802 a1xa2(3) = lattice_vectors(1,1)*lattice_vectors(2,2) - lattice_vectors(1,2)*lattice_vectors(2,1)
1804 a2xa3(1) = lattice_vectors(2,2)*lattice_vectors(3,3) - lattice_vectors(2,3)*lattice_vectors(3,2)
1805 a2xa3(2) = -lattice_vectors(2,1)*lattice_vectors(3,3) + lattice_vectors(2,3)*lattice_vectors(3,1)
1806 a2xa3(3) = lattice_vectors(2,1)*lattice_vectors(3,2) - lattice_vectors(2,2)*lattice_vectors(3,1)
1808 a3xa1(1) = lattice_vectors(3,2)*lattice_vectors(1,3) - lattice_vectors(3,3)*lattice_vectors(1,2)
1809 a3xa1(2) = -lattice_vectors(3,1)*lattice_vectors(1,3) + lattice_vectors(3,3)*lattice_vectors(1,1)
1810 a3xa1(3) = lattice_vectors(3,1)*lattice_vectors(1,2) - lattice_vectors(3,2)*lattice_vectors(1,1)
1813 volr = lattice_vectors(1,1)*a2xa3(1)+ lattice_vectors(1,2)*a2xa3(2)+lattice_vectors(1,3)*a2xa3(3)
1816 recip_vectors(1,:) = 2.0_dp*pi*a2xa3(:)/volr
1817 recip_vectors(2,:) = 2.0_dp*pi*a3xa1(:)/volr
1818 recip_vectors(3,:) = 2.0_dp*pi*a1xa2(:)/volr
1820 b2xb3(1) = recip_vectors(2,2)*recip_vectors(3,3) - recip_vectors(2,3)*recip_vectors(3,2)
1821 b2xb3(2) = -recip_vectors(2,1)*recip_vectors(3,3) + recip_vectors(2,3)*recip_vectors(3,1)
1822 b2xb3(3) = recip_vectors(2,1)*recip_vectors(3,2) - recip_vectors(2,2)*recip_vectors(3,1)
1824 volk = recip_vectors(1,1)*b2xb3(1)+ recip_vectors(1,2)*b2xb3(2)+recip_vectors(1,3)*b2xb3(3)
1838 real(
dp) :: mv1, mv2, v1(3), v2(3)
1839 real(
dp) :: dotprod, cosdir, v2xv20(3), v1xv10(3)
1840 real(
dp) :: v10(3),v20(3), cprod(3), normcprod, sindir
1841 real(
dp),
intent(in) :: coords(:,:)
1842 real(
dp),
intent(out) :: dihedral
1844 integer,
intent(in) :: id1,id2,id3,id4
1845 character(2) :: index1, index2, index3, index4
1847 v1=coords(:,id4) - coords(:,id3)
1848 v10=coords(:,id2) - coords(:,id3)
1849 v2=coords(:,id1) - coords(:,id2)
1850 v20=coords(:,id3) - coords(:,id2)
1852 v1xv10(1)=v1(2)*v10(3)-v1(3)*v10(2)
1853 v1xv10(2)=-(v1(1)*v10(3)-v1(3)*v10(1))
1854 v1xv10(3)=v1(1)*v10(2)-v1(2)*v10(1)
1856 v2xv20(1)=v2(2)*v20(3)-v2(3)*v20(2)
1857 v2xv20(2)=-(v2(1)*v20(3)-v2(3)*v20(1))
1858 v2xv20(3)=v2(1)*v20(2)-v2(2)*v20(1)
1860 dotprod = v1xv10(1)*v2xv20(1) + v1xv10(2)*v2xv20(2) + v1xv10(3)*v2xv20(3)
1862 cprod(1)=v1xv10(2)*v2xv20(3)-v1xv10(3)*v2xv20(2)
1863 cprod(2)=-(v1xv10(1)*v2xv20(3)-v1xv10(3)*v2xv20(1))
1864 cprod(3)=v1xv10(1)*v2xv20(2)-v1xv10(2)*v2xv20(1)
1866 normcprod=sqrt(cprod(1)*cprod(1) + cprod(2)*cprod(2) + cprod(3)*cprod(3))
1868 mv1= sqrt(v1xv10(1)*v1xv10(1) + v1xv10(2)*v1xv10(2) + v1xv10(3)*v1xv10(3))
1869 mv2= sqrt(v2xv20(1)*v2xv20(1) + v2xv20(2)*v2xv20(2) + v2xv20(3)*v2xv20(3))
1871 cosdir = dotprod/(mv1*mv2)
1872 sindir = normcprod/(mv1*mv2)
1875 dihedral=sign(1.0d0,sindir)*acos(-cosdir)
1876 dihedral=-360*dihedral/(2.0*3.14159265359)
1877 if(dihedral < 0)dihedral = 360 + dihedral
1893 character(20),
intent(in) :: bml_type
1894 integer :: i, j, jj, mymdim
1895 integer,
intent(in) :: mdimin
1896 integer,
intent(in) :: nnstruct(:,:), nrnnstruct(:)
1897 integer,
optional,
intent(in) :: verbose
1898 real(
dp) :: d, dvdw, factor, ra(3),rb(3),rab(3)
1899 real(
dp) :: lx, ly, lz
1900 type(bml_matrix_t),
intent(inout) :: gcov_bml
1902 logical(1),
allocatable :: ispresent(:)
1903 real(kind(1.0)),
allocatable :: row(:)
1905 if(bml_get_n(gcov_bml).gt.0)
call bml_deallocate(gcov_bml)
1913 call bml_zero_matrix(bml_type,bml_element_real,kind(1.0),sy%nats,mymdim,gcov_bml)
1916 lx = sy%lattice_vector(1,1)
1917 ly = sy%lattice_vector(2,2)
1918 lz = sy%lattice_vector(3,3)
1920 if(
present(verbose))
then
1921 if(verbose >= 1)
then
1923 write(*,*)
"Building covalency graph ..."
1928 allocate(ispresent(sy%nats))
1931 ra = sy%coordinate(:,i)
1933 do j=1,nrnnstruct(i)
1935 if(nrnnstruct(i) <= 1)
write(*,*)
"WARNING: Atom" ,i,
"is desconnected"
1938 if(.not.ispresent(jj))
then
1939 rb = sy%coordinate(:,jj)
1941 rab(1) = modulo((rb(1) - ra(1) + lx/2.0_dp),lx) - lx/2.0_dp
1942 rab(2) = modulo((rb(2) - ra(2) + ly/2.0_dp),ly) - ly/2.0_dp
1943 rab(3) = modulo((rb(3) - ra(3) + lz/2.0_dp),lz) - lz/2.0_dp
1947 if(d == 0.0_dp .and. i .ne. jj)
write(*,*)
"WARNING: Atom" ,i,
"and atom",jj,&
1948 "are on top of each other"
1950 if(d < dvdw .and. d > 0.0_dp)
then
1951 ispresent(jj) = .true.
1954 call bml_set_element_new(gcov_bml,i,jj,1.0)
1963 deallocate(ispresent)
1970 character(20),
intent(in) :: bml_type
1971 integer :: i, j, jj, mymdim
1972 integer,
intent(in) :: mdimin
1973 integer,
intent(in) :: nnStruct(:,:), nrnnstruct(:)
1974 integer,
optional,
intent(in) :: verbose
1975 real(dp) :: d, dvdw, factor
1976 real(dp),
intent(in) :: nnStructMindist(:,:)
1977 type(bml_matrix_t),
intent(inout) :: gcov_bml
1980 if(bml_get_n(gcov_bml).gt.0)
call bml_deallocate(gcov_bml)
1988 call bml_zero_matrix(bml_type,bml_element_real,dp,sy%nats,mymdim,gcov_bml)
1990 if(
present(verbose))
then
1991 if(verbose >= 1)
then
1993 write(*,*)
"Building covalency graph ..."
1999 do j=1,nrnnstruct(i)
2000 if(nrnnstruct(i) <= 1)
write(*,*)
"WARNING: Atom" ,i,
"is desconnected"
2002 d = nnstructmindist(j,i)
2003 if(d == 0.0_dp .and. i .ne. jj)
write(*,*)
"WARNING: Atom" ,i,
"and atom",j,&
2004 "are on top of each other"
2006 if(d < dvdw .and. d > 0.0_dp)
then
2007 call bml_set_element_new(gcov_bml,i,jj,1.0_dp)
2008 call bml_set_element_new(gcov_bml,jj,i,1.0_dp)
2011 call bml_set_element_new(gcov_bml,i,i,1.0_dp)
2028 graph_h,mdimin,verbose)
2030 integer :: i, j, jj, ncount, mymdim
2031 integer,
intent(in) :: nnstruct(:,:), nrnnstruct(:), mdimin
2032 integer,
optional,
intent(in) :: verbose
2033 real(
dp) :: d, dvdw, ra(3),rb(3),rab(3)
2034 real(
dp) :: lx, ly, lz
2035 real(
dp),
intent(in) :: rcut
2036 integer,
allocatable,
intent(inout) :: graph_h(:,:)
2046 if(.not.
allocated(graph_h))
allocate(graph_h(mymdim,sy%nats))
2048 if(
present(verbose))
then
2049 if(verbose >= 1)
then
2051 write(*,*)
"Building H covalency graph ..."
2058 lx = sy%lattice_vector(1,1)
2059 ly = sy%lattice_vector(2,2)
2060 lz = sy%lattice_vector(3,3)
2067 do j=1,nrnnstruct(i)
2069 ra=sy%coordinate(:,i)
2070 rb=sy%coordinate(:,jj)
2071 rab(1) = modulo((rb(1) - ra(1) + lx/2.0_dp),lx) - lx/2.0_dp
2072 rab(2) = modulo((rb(2) - ra(2) + ly/2.0_dp),ly) - ly/2.0_dp
2073 rab(3) = modulo((rb(3) - ra(3) + lz/2.0_dp),lz) - lz/2.0_dp
2077 if(d.lt.rcut.and.d.gt.0.0_dp)
then
2079 graph_h(ncount,i) = jj
2099 integer :: i, nsptmp, prev
2100 integer,
intent(in) :: indices(:), lsize
2101 integer,
optional,
intent(in) :: verbose
2105 if(
present(verbose))
then
2106 if(verbose >= 1)
then
2108 write(*,*)
"Extracting subsystem ..."
2115 if(
allocated(sbsy%symbol))
then
2116 deallocate(sbsy%symbol)
2117 deallocate(sbsy%coordinate)
2118 deallocate(sbsy%atomic_number)
2119 deallocate(sbsy%velocity)
2120 deallocate(sbsy%force)
2121 deallocate(sbsy%net_charge)
2122 deallocate(sbsy%mass)
2123 deallocate(sbsy%lattice_vector)
2124 deallocate(sbsy%spindex)
2127 allocate(sbsy%symbol(sbsy%nats))
2128 allocate(sbsy%coordinate(3,sbsy%nats))
2129 allocate(sbsy%atomic_number(sbsy%nats))
2130 allocate(sbsy%velocity(3,sbsy%nats))
2131 allocate(sbsy%force(3,sbsy%nats))
2132 allocate(sbsy%net_charge(sbsy%nats))
2133 allocate(sbsy%mass(sbsy%nats))
2134 allocate(sbsy%lattice_vector(3,3))
2135 allocate(sbsy%spindex(sbsy%nats))
2139 sbsy%lattice_vector = sy%lattice_vector
2144 sbsy%symbol(i) = sy%symbol(indices(i)+1)
2145 sbsy%coordinate(:,i) = sy%coordinate(:,indices(i)+1)
2146 sbsy%atomic_number(i) = sy%atomic_number(indices(i)+1)
2147 sbsy%mass(i) = sy%mass(indices(i)+1)
2148 sbsy%spindex(i) = sy%spindex(indices(i)+1)
2149 if(sbsy%spindex(i).gt.nsptmp)
then
2154 if(nsptmp.lt.sy%nsp)
then
2155 write(*,*)
"WARNING: nsp = ",nsptmp,sy%nsp
2156 write(*,*)
"The subsystem contains less species that the system ..."
2157 write(*,*)
"A generalization to parts where subsystem contains"
2158 write(*,*)
"less species that the system needs to be added ..."
2159 write(*,*)
"See prg_get_subsystem in prg_system_mod"
2165 if(
allocated(sbsy%spatnum))
then
2166 deallocate(sbsy%spatnum)
2167 deallocate(sbsy%spmass)
2170 allocate(sbsy%spatnum(sbsy%nsp))
2171 allocate(sbsy%spmass(sbsy%nsp))
2173 sbsy%spatnum = sy%spatnum
2174 sbsy%spmass = sy%spmass
2188 integer,
optional,
intent(in) :: verbose
2191 if(
present(verbose))
then
2192 if(verbose >= 1)
then
2194 write(*,*)
"Deallocating the multiple subsystem ..."
2200 if(
allocated(sbsy%symbol))
then
2201 deallocate(sbsy%symbol)
2202 deallocate(sbsy%coordinate)
2203 deallocate(sbsy%atomic_number)
2204 deallocate(sbsy%velocity)
2205 deallocate(sbsy%force)
2206 deallocate(sbsy%net_charge)
2207 deallocate(sbsy%mass)
2208 deallocate(sbsy%spindex)
2211 if(
allocated(sbsy%lattice_vector))
deallocate(sbsy%lattice_vector)
2212 if(
allocated(sbsy%resindex))
deallocate(sbsy%resindex)
2214 if(
allocated(sbsy%spatnum))
then
2215 deallocate(sbsy%spatnum)
2216 deallocate(sbsy%spmass)
2219 if(bml_get_n(sbsy%estr%ham) > 0)
call bml_deallocate(sbsy%estr%ham)
2220 if(bml_get_n(sbsy%estr%ham0) > 0)
call bml_deallocate(sbsy%estr%ham0)
2221 if(bml_get_n(sbsy%estr%oham) > 0)
call bml_deallocate(sbsy%estr%oham)
2222 if(bml_get_n(sbsy%estr%over) > 0)
call bml_deallocate(sbsy%estr%over)
2223 if(bml_get_n(sbsy%estr%rho) > 0)
call bml_deallocate(sbsy%estr%rho)
2224 if(bml_get_n(sbsy%estr%orho) > 0)
call bml_deallocate(sbsy%estr%orho)
2225 if(bml_get_n(sbsy%estr%zmat) > 0)
call bml_deallocate(sbsy%estr%zmat)
2228 if(
allocated(sbsy%estr%coul_pot_r))
deallocate(sbsy%estr%coul_pot_r)
2229 if(
allocated(sbsy%estr%coul_pot_k))
deallocate(sbsy%estr%coul_pot_k)
2230 if(
allocated(sbsy%estr%skforce))
deallocate(sbsy%estr%skforce)
2231 if(
allocated(sbsy%estr%fpul))
deallocate(sbsy%estr%fpul)
2232 if(
allocated(sbsy%estr%fscoul))
deallocate(sbsy%estr%fscoul)
2233 if(
allocated(sbsy%estr%hindex))
deallocate(sbsy%estr%hindex)
2251 character(2),
intent(in) :: hetatm
2252 integer :: cnt, i, j, jj
2253 integer :: maxparts, nmax
2254 integer,
allocatable :: core_count(:), cores(:,:), partof(:)
2255 integer,
intent(in) :: nnstruct(:,:), nrnnstruct(:)
2256 integer,
intent(inout) :: npart
2257 integer,
optional,
intent(inout) :: verbose
2258 logical,
allocatable :: inpart(:)
2260 real(
dp),
intent(in) :: nnstructmindist(:,:)
2264 if(
present(verbose))
then
2265 if(verbose >= 1)
then
2266 write(*,*)
" ";
write(*,*)
"Partitioning by molecule ...";
write(*,*)
" "
2270 if(
allocated(gp%nnodesInPart))
then
2277 allocate(core_count(maxparts))
2279 allocate(cores(nmax,maxparts))
2280 allocate(inpart(sy%nats))
2281 allocate(partof(sy%nats))
2289 if(.not.inpart(i).and.trim(sy%symbol(i)) == trim(hetatm))
then
2291 core_count(npart) = core_count(npart) + 1
2292 cores(core_count(npart),npart) = i
2294 do j=1,nrnnstruct(i)
2296 d = nnstructmindist(j,i)
2298 if(d.lt.dvdw.and.d.gt.0.001_dp)
then
2299 if(.not.inpart(jj))
then
2300 core_count(npart) = core_count(npart) + 1
2301 cores(core_count(npart),npart) = jj
2315 gp%nnodesInPartAll(i) = core_count(i)
2317 allocate(gp%sgraph(i)%nodeInPart(core_count(i)))
2318 gp%nnodesInPart(i) = core_count(i)
2323 do j=1,core_count(i)
2324 gp%sgraph(i)%nodeInPart(j) = cores(j,i) - 1
2340 character(20) :: bml_type
2341 integer :: i, ii, j, jj
2342 integer :: nch, norbs
2343 integer,
intent(in) :: hindex(:,:)
2344 integer,
optional,
intent(in) :: verbose
2345 logical :: connection
2346 logical,
allocatable :: iconnectedtoj(:)
2347 real(
dp),
allocatable :: row(:), rowat(:)
2348 real(
dp),
intent(in) :: threshold
2349 type(bml_matrix_t),
intent(in) :: rho_bml
2350 type(bml_matrix_t),
intent(inout) :: gch_bml
2352 norbs = bml_get_n(rho_bml)
2353 bml_type = bml_get_type(rho_bml)
2354 nch =
size(hindex,dim=2)
2355 allocate(rowat(nch))
2356 allocate(row(norbs))
2357 allocate(iconnectedtoj(nch))
2359 if(bml_get_n(gch_bml) > 0)
call bml_deallocate(gch_bml)
2360 call bml_zero_matrix(bml_type,bml_element_real,
dp,nch,nch,gch_bml)
2364 do ii = hindex(1,i),hindex(2,i)
2365 call bml_get_row(rho_bml,ii,row)
2366 iconnectedtoj = .false.
2368 connection = .false.
2370 if(.not.iconnectedtoj(j).and.rowat(j) == 0)
then
2371 do jj = hindex(1,j),hindex(2,j)
2372 if(abs(row(jj)) > threshold)
then
2377 if(connection) iconnectedtoj(j) = .true.
2379 if(connection) rowat(j) = 1.0_dp
2383 call bml_set_row(gch_bml,i,rowat)
2388 deallocate(iconnectedtoj)
2406 character(20) :: bml_type
2407 integer :: i, ifull, ii, j
2408 integer :: jfull, jj, ncounti
2409 integer :: norbs, mymdim
2410 logical(1),
allocatable :: rowatfull(:)
2411 integer,
allocatable,
intent(inout) :: graph_p(:,:)
2412 integer,
intent(in) :: chindex(:), hindex(:,:), nats, nc
2414 integer,
intent(in) :: mdimin
2415 integer,
optional,
intent(in) :: verbose
2416 logical :: connection
2417 logical,
allocatable :: iconnectedtoj(:)
2418 real(
dp),
allocatable :: row(:)
2419 real(
dp),
intent(in) :: threshold
2420 type(bml_matrix_t),
intent(in) :: rho_bml
2422 norbs = bml_get_n(rho_bml)
2423 bml_type = bml_get_type(rho_bml)
2424 nch =
size(hindex,dim=2)
2425 allocate(rowatfull(nats))
2426 allocate(row(norbs))
2427 allocate(iconnectedtoj(nch))
2435 if(.not.
allocated(graph_p))
then
2436 allocate(graph_p(mymdim,nats))
2437 write(*,*)
"PRG_COLLECT_GRAPH_P: Allocated graph_p"
2447 ifull = chindex(i) + 1
2448 if(ifull.gt.nats)
write(*,*)
"PRG_COLLECT_GRAPH_P: ifull > nats"
2452 do while (graph_p(ii,ifull).ne.0)
2453 rowatfull(graph_p(ii,ifull)) = .true.
2454 ncounti = ncounti + 1
2457 do ii = hindex(1,i),hindex(2,i)
2458 call bml_get_row(rho_bml,ii,row)
2459 iconnectedtoj = .false.
2462 jfull = chindex(j) + 1
2463 if(jfull.gt.nats)
write(*,*)
"PRG_COLLECT_GRAPH_P: jfull > nats"
2464 connection = .false.
2465 if(.not.iconnectedtoj(j).and..not.rowatfull(jfull))
then
2466 do jj = hindex(1,j),hindex(2,j)
2467 if(abs(row(jj)) > threshold)
then
2472 if(connection) iconnectedtoj(j) = .true.
2476 rowatfull(jfull) = .true.
2477 ncounti = ncounti + 1
2478 graph_p(ncounti,ifull) = jfull
2485 deallocate(rowatfull)
2486 deallocate(iconnectedtoj)
2502 subroutine prg_collect_extended_graph_p(rho_bml,nc,nats,hindex,chindex,graph_p,threshold,mdimin,alpha,coords,coordsall,latticevectors,verbose)
2504 character(20) :: bml_type
2505 integer :: i, ifull, ii, j, k
2506 integer :: jfull, jj, nch, ncounti
2507 integer :: norbs, mymdim,chindex_size
2508 logical(1),
allocatable :: rowatfull(:)
2509 integer,
allocatable,
intent(inout) :: graph_p(:,:)
2510 integer,
intent(in) :: chindex(:), hindex(:,:), nats, nc
2511 integer,
intent(in) :: mdimin
2512 integer,
optional,
intent(in) :: verbose
2513 logical :: connection
2514 logical,
allocatable :: iconnectedtoj(:)
2516 real(4),
allocatable :: row(:),extmat(:,:),dvec(:,:),dr2(:)
2517 real(4),
allocatable :: rho(:,:), rho_red(:,:), rhoext(:,:)
2519 real(
dp),
allocatable :: row(:),extmat(:,:),dvec(:,:),dr2(:)
2520 real(
dp),
allocatable :: rho(:,:), rho_red(:,:), rhoext(:,:)
2522 integer,
allocatable :: graph_core(:,:)
2523 real(
dp),
intent(in) :: alpha,threshold
2524 real(
dp),
allocatable,
intent(in) :: latticevectors(:,:)
2525 real(
dp),
allocatable,
intent(in) :: coords(:,:),coordsall(:,:)
2526 real(
dp) :: lx, ly, lz, dvx, dvy, dvz, val
2527 type(bml_matrix_t),
intent(inout) :: rho_bml
2529 type(c_ptr) :: rho_bml_c_ptr
2531 real(c_double),
pointer :: rho_bml_ptr(:,:)
2532 logical(1),
allocatable :: graphed(:,:)
2535 chindex_size =
size(chindex)
2536 norbs = bml_get_n(rho_bml)
2537 bml_type = bml_get_type(rho_bml)
2538 nch =
size(hindex,dim=2)
2539 allocate(rowatfull(nats))
2540 allocate(row(norbs))
2541 allocate(iconnectedtoj(nats))
2542 allocate(dvec(3,nats))
2544 allocate(extmat(nats,nch))
2545 allocate(rho_red(nch,nc))
2559 if(.not.
allocated(graph_p))
then
2560 write(*,*)
"PRG_COLLECT_GRAPH_P: graph_p not allocated on entry, so allocating"
2561 allocate(graph_p(mymdim,nats))
2564 if((
size(graph_p,dim=1).ne.mymdim).or.(
size(graph_p,dim=2).ne.nats))
then
2565 write(*,*)
"PRG_COLLECT_GRAPH_P: graph_p has wrong shape. mdim=",mymdim,
",nats=",nats,
",shape=",shape(graph_p)
2570 lx = latticevectors(1,1)
2571 ly = latticevectors(2,2)
2572 lz = latticevectors(3,3)
2574 allocate(graphed(nats,nc))
2575 allocate(rhoext(nats,nc))
2576 allocate(graph_core(mymdim,nc))
2578 rho_bml_c_ptr = bml_get_data_ptr_dense(rho_bml)
2579 ld = bml_get_ld_dense(rho_bml)
2580 call c_f_pointer(rho_bml_c_ptr,rho_bml_ptr,shape=[ld,norbs])
2591 dvx = modulo((coordsall(1,j) - coords(1,i) + lx/2.0_dp),lx) - lx/2.0_dp
2592 dvy = modulo((coordsall(2,j) - coords(2,i) + ly/2.0_dp),ly) - ly/2.0_dp
2593 dvz = modulo((coordsall(3,j) - coords(3,i) + lz/2.0_dp),lz) - lz/2.0_dp
2594 extmat(j,i) = exp(-alpha*(dvx*dvx+dvy*dvy+dvz*dvz))
2603 rho_red(i,j) = maxval(abs(rho_bml_ptr(hindex(1,j):hindex(2,j),hindex(1,i):hindex(2,i))))
2611 rhoext(j,i) = 0.0_dp
2613 rhoext(j,i) = rhoext(j,i) + extmat(j,k)*rho_red(k,i)
2623 ifull = chindex(i) + 1
2626 graphed(j,i) = .false.
2631 graph_core(ii,i) = 0
2636 if (rho_red(j,i).ge.threshold)
then
2637 graphed(chindex(j)+1,i) = .true.
2643 if ((rhoext(j,i).ge.threshold).or.graphed(j,i))
then
2644 ncounti = ncounti + 1
2645 graph_core(ncounti,i) = j
2657 graph_p(:,chindex(i) + 1) = graph_core(:,i)
2662 deallocate(graph_core)
2664 allocate(rho(norbs,norbs))
2666 call bml_export_to_dense(rho_bml,rho)
2675 dvec(1,:) = modulo((coordsall(1,:) - coords(1,i) + lx/2.0_dp),lx) - lx/2.0_dp
2676 dvec(2,:) = modulo((coordsall(2,:) - coords(2,i) + ly/2.0_dp),ly) - ly/2.0_dp
2677 dvec(3,:) = modulo((coordsall(3,:) - coords(3,i) + lz/2.0_dp),lz) - lz/2.0_dp
2678 dr2(:) = dvec(1,:)*dvec(1,:) + dvec(2,:)*dvec(2,:) + dvec(3,:)*dvec(3,:)
2679 extmat(:,i) = exp(-alpha*dr2(:))
2688 rho_red(i,j) = maxval(rho(hindex(1,i):hindex(2,i),hindex(1,j):hindex(2,j)))
2692 allocate(rhoext(nats,nc))
2697 rhoext(j,i) = 0.0_dp
2699 rhoext(j,i) = rhoext(j,i) + extmat(j,k)*rho_red(k,i)
2710 ifull = chindex(i) + 1
2714 do while (graph_p(ii,ifull).ne.0)
2715 rowatfull(graph_p(ii,ifull)) = .true.
2716 ncounti = ncounti + 1
2720 jfull = chindex(j) + 1
2721 if ((rho_red(j,i).ge.threshold).and.(.not.rowatfull(jfull)))
then
2722 ncounti = ncounti + 1
2723 graph_p(ncounti,ifull) = jfull
2724 rowatfull(jfull) = .true.
2728 if ((rhoext(j,i).ge.threshold).and.(.not.rowatfull(j)))
then
2729 ncounti = ncounti + 1
2730 graph_p(ncounti,ifull) = j
2738 deallocate(rowatfull)
2739 deallocate(iconnectedtoj)
2755 integer :: i, ii, j, nats
2756 integer :: ncounti, maxnz
2757 integer,
intent(inout) :: graph_h(:,:)
2758 integer,
intent(inout) :: graph_p(:,:)
2759 logical,
allocatable :: rowpatfull(:)
2761 nats =
size(graph_p,dim=2)
2762 maxnz =
size(graph_p,dim=1)
2764 if(.not.
allocated(rowpatfull))
allocate(rowpatfull(nats))
2771 rowpatfull = .false.
2774 do while ((graph_p(ii,i).ne.0).and.(ii.le.maxnz))
2775 if(graph_p(ii,i).gt.nats)
then
2776 write(*,*)
"PRG_MERGE_GRAPH: graph_p(",ii,
",",i,
") has value ",graph_p(ii,i),
" which exceeds nats = ",nats
2779 rowpatfull(graph_p(ii,i)) = .true.
2780 ncounti = ncounti + 1
2785 do while ((graph_h(ii,i).ne.0).and.(ii.le.maxnz))
2787 if(.not.rowpatfull(j))
then
2788 ncounti = ncounti + 1
2789 graph_p(ncounti,i) = j
2796 deallocate(rowpatfull)
2810 integer :: i, ii, j, nats
2811 integer :: ncounti, ncountot
2812 integer,
allocatable,
intent(inout) :: adjncy(:), graph_h(:,:), graph_p(:,:), xadj(:)
2813 logical(1),
allocatable :: rowpatfull(:)
2815 nats =
size(graph_p,dim=2)
2816 allocate(rowpatfull(nats))
2817 allocate(xadj(nats+1))
2818 allocate(adjncy(nats*nats))
2828 rowpatfull = .false.
2830 do while (graph_p(ii,i).ne.0)
2831 rowpatfull(graph_p(ii,i)) = .true.
2832 ncounti = ncounti + 1
2837 do while (graph_h(ii,i).ne.0)
2839 if(.not.rowpatfull(j))
then
2840 ncounti = ncounti + 1
2841 ncountot = ncountot + 1
2842 graph_p(ncounti,i) = j
2858 do while (graph_p(ii,i).gt.0)
2859 ncounti = ncounti + 1
2860 ncountot = ncountot + 1
2861 adjncy(ncountot) = graph_p(ii,i)
2864 xadj(i) = ncountot - ncounti + 1
2868 xadj(nats+1) = ncountot + 1
2870 deallocate(rowpatfull)
2884 character(20),
intent(in) :: bml_type
2885 integer :: i, ii, j, nats
2886 integer,
intent(in) :: adjncy(:), xadj(:)
2887 real(
dp),
allocatable :: row(:)
2888 type(bml_matrix_t),
intent(inout) :: g_bml
2890 nats =
size(xadj,dim=1) - 1
2891 if(bml_get_n(g_bml).gt.0)
call bml_deallocate(g_bml)
2892 call bml_zero_matrix(bml_type,bml_element_real,
dp,nats,nats,g_bml)
2900 do j = xadj(i), xadj(i+1) - 1
2901 row(adjncy(j)) = 1.0_dp
2903 call bml_set_row(g_bml,i,row)
2918 character(20),
intent(in) :: bml_type
2919 integer :: i, ii, nats, mymdim
2920 integer,
allocatable,
intent(inout) :: graph(:,:)
2922 real(kind(1.0)),
allocatable :: row(:)
2923 type(bml_matrix_t),
intent(inout) :: g_bml
2925 nats =
size(graph,dim=2)
2930 mymdim = bml_get_m(g_bml)
2931 write(*,*)
"mdim",mymdim
2938 do while (graph(ii,i).gt.0)
2939 if(graph(ii,i).gt.nats)
then
2940 write(*,*)
"prg_graph2bml ERROR: nats < graph(",ii,
",",i,
") = ",graph(ii,i)
2943 row(graph(ii,i)) = 1.0_dp
2948 call bml_set_row(g_bml,i,row,0.5_dp)
2965 integer,
intent(inout) :: graph(:,:)
2966 integer,
allocatable :: vector(:)
2967 integer :: i, j, maxnz, nats, ncount
2969 nats =
size(graph,dim=2)
2970 allocate(vector(nats*maxnz))
2979 ncount = (i-1)*maxnz + j
2980 vector(ncount) = graph(j,i)
2994 integer,
intent(inout) :: graph(:,:)
2995 integer,
allocatable,
intent(inout) :: vector(:)
2996 integer :: i, j, maxnz, nats, ncount
2998 nats =
size(graph,dim=2)
3006 ncount = (i-1)*maxnz + j
3007 graph(j,i) = vector(ncount)
3022 integer,
intent(inout) :: xadj(:)
3023 integer,
allocatable,
intent(inout) :: adjncy(:)
3024 integer :: i, j, n, l, first, last, nx, irank, mintmp
3025 integer,
allocatable :: tmpvect(:), newadjncy(:)
3027 nx =
size(xadj,dim=1)
3028 allocate(tmpvect(nx))
3029 allocate(newadjncy(xadj(nx) - 1))
3036 last = xadj(i+1) - 1
3037 write(*,*)first,last
3038 n = last - first + 1
3040 tmpvect(1:n) = adjncy(first:last)
3044 if(tmpvect(j) >= tmpvect(l).and.tmpvect(l).ne.0)
then
3046 tmpvect(l) = tmpvect(j)
3052 adjncy(first:last) = tmpvect(1:n)
3053 newadjncy(first:last) = tmpvect(1:n)
3060 allocate(adjncy(xadj(nx) - 1))
3064 deallocate(newadjncy)
subroutine, public prg_initgraphpartitioning(gp, pname, np, nnodes, nnodes2)
Initialize graph partitioning.
subroutine, public prg_initsubgraph(sg, pnum, hsize)
Initialize subgraph.
subroutine, public prg_destroygraphpartitioning(gp)
Destroy graph partitioning.
Module to handle input output files for the PROGRESS lib.
integer function, public get_file_unit(io_max)
Returns a unit number that is not in use.
subroutine, public prg_open_file(io, name)
Opens a file to write.
subroutine, public prg_open_file_to_read(io, name)
Opens a file to read.
Periodic table of elements.
real(dp), dimension(nz), parameter element_covr
Covalent radius (in Angstroms)
character(2), dimension(nz), parameter element_symbol
Element symbol.
integer function, public element_atomic_number(symbol)
integer function element_atomic_number_upper(symbol)
real(dp), dimension(nz), parameter element_mass
Element mass in atomic mass units (1.66 x 10-27 kg)
A module to read and handle chemical systems.
subroutine, public prg_get_subsystem(sy, lsize, indices, sbsy, verbose)
Get a subsystem out of the total system.
subroutine, public prg_adj2bml(xadj, adjncy, bml_type, g_bml)
prg_adj2bml
subroutine, public prg_destroy_subsystems(sbsy, verbose)
Destroy allocated subsystem.
subroutine, public prg_parameters_to_vectors(abc_angles, lattice_vector)
Transforms the lattice parameters into lattice vectors.
subroutine, public prg_translatetogeomcandfoldtobox(coords, lattice_vectors, origin)
Translate to geometric center.
subroutine, public prg_collect_extended_graph_p(rho_bml, nc, nats, hindex, chindex, graph_p, threshold, mdimin, alpha, coords, coordsall, latticevectors, verbose)
Collect the small graph to build the full graph.
subroutine, public prg_replicate_system(sy, syf, nx, ny, nz)
Extend/replicate a system type along the lattice vectors.
subroutine, public prg_get_dihedral(coords, id1, id2, id3, id4, dihedral)
Get the dihedral angle given four atomic positions.
subroutine, public prg_graph2bml(graph, bml_type, g_bml)
Graph2bml.
subroutine, public prg_write_trajectory(system, iter, each, prg_deltat, filename, extension)
Write trajectory in .xyz, .dat or pdb file.
subroutine prg_get_covgraph_int(sy, nnStructMindist, nnStruct, nrnnstruct, bml_type, factor, gcov_bml, mdimin, verbose)
subroutine, public prg_molpartition(sy, npart, nnStructMindist, nnStruct, nrnnstruct, hetatm, gp, verbose)
Partition by molecule.
subroutine, public prg_make_random_system(system, nats, seed, lx, ly, lz)
Make random Xx system.
subroutine, public prg_cleanuprepeatedatoms(nats, coords, symbols, verbose)
Cleanup repeated atoms we might have in the system.
subroutine, public prg_merge_graph_adj(graph_p, graph_h, xadj, adjncy)
Get partial subgraph based on the Density matrix.
subroutine, public prg_graph2vector(graph, vector, maxnz)
Vectorize graph.
subroutine, public prg_get_covgraph(sy, nnStruct, nrnnstruct, bml_type, factor, gcov_bml, mdimin, verbose)
Get the covalency graph in bml format.
subroutine, public prg_write_trajectoryandproperty(system, iter, each, prg_deltat, scalarprop, filename, extension)
Write trajectory and atomic properties. Only pdb file.
subroutine, public prg_vector2graph(vector, graph, maxnz)
Back to graph.
subroutine, public prg_translateandfoldtobox(coords, lattice_vectors, origin, verbose)
Translate and fold to box.
subroutine, public prg_wraparound(coords, lattice_vectors, index, verbose)
Wrap around atom i using pbc.
subroutine, public prg_destroy_estr(estr)
Deallocates all the arrays within the electronic structure.
subroutine, public prg_get_covgraph_h(sy, nnStruct, nrnnstruct, rcut, graph_h, mdimin, verbose)
Get the covanlency graph.
subroutine, public prg_get_distancematrix(coords, dmat)
Get the distance matrix.
subroutine, public prg_get_nameandext(fullfilename, filename, ext)
Get the name and extension of a file.
subroutine, public prg_get_partial_atomgraph(rho_bml, hindex, gch_bml, threshold, verbose)
Get partial subgraph based on the Density matrix.
subroutine, public prg_destroy_system(sy)
Deallocates all the arrays within a system.
subroutine, public prg_parse_system(system, filename, extin)
The parser for the chemical system.
subroutine, public prg_centeratbox(coords, lattice_vectors, verbose)
Translate geometric center to the center of the box.
subroutine, public prg_vectors_to_parameters(lattice_vector, abc_angles)
Transforms the lattice vectors into lattice parameters.
subroutine, public prg_merge_graph(graph_p, graph_h)
Get partial subgraph based on the Density matrix.
subroutine, public prg_replicate(coords, symbols, lattice_vectors, nx, ny, nz)
Extend/replicate system along lattice vectors.
subroutine, public prg_write_system(system, filename, extin)
Write system in .xyz, .dat or pdb file.
subroutine, public prg_get_recip_vects(lattice_vectors, recip_vectors, volr, volk)
Get the volume of the cell and the reciprocal vectors: This soubroutine computes:
subroutine, public prg_sortadj(xadj, adjncy)
Sort adj NOTE: this might not be needed anymre since the bml_get_adj routine is sorting the values.
subroutine, public prg_get_origin(coords, origin)
Get the origin of the coordinates.
subroutine, public prg_collect_graph_p(rho_bml, nc, nats, hindex, chindex, graph_p, threshold, mdimin, verbose)
Collect the small graph to build the full graph.
Electronic structure type.