Skip to content

Commit

Permalink
Merge branch 'fft_rewrite'
Browse files Browse the repository at this point in the history
  • Loading branch information
aoterodelaroza committed Nov 6, 2024
2 parents df844de + 358c766 commit fcd1133
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 285 deletions.
37 changes: 18 additions & 19 deletions src/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,10 @@ module subroutine field_new(f,seed,c,id,sptr,errmsg,ti)
ifformat_xsf, ifformat_elkgrid, ifformat_siestagrid, ifformat_fplogrid,&
ifformat_dftb, ifformat_pwc, ifformat_fmt,&
ifformat_wfn, ifformat_wfx, ifformat_fchk, ifformat_molden, ifformat_as,&
ifformat_as_promolecular, ifformat_as_core, ifformat_as_lap, ifformat_as_grad,&
ifformat_as_pot, ifformat_as_resample,&
ifformat_as_promolecular, ifformat_as_core, ifformat_as_resample,&
ifformat_as_ft_x,ifformat_as_ft_y,ifformat_as_ft_z,ifformat_as_ft_xx,&
ifformat_as_ft_xy,ifformat_as_ft_xz,ifformat_as_ft_yy,ifformat_as_ft_yz,&
ifformat_as_ft_zz,ifformat_as_ft_grad,ifformat_as_ft_lap,ifformat_as_ft_pot,&
ifformat_as_clm, ifformat_as_clm_sub, ifformat_as_ghost, &
ifformat_copy, ifformat_promolecular, ifformat_promolecular_fragment
use hashmod, only: hash
Expand Down Expand Up @@ -585,8 +587,13 @@ module subroutine field_new(f,seed,c,id,sptr,errmsg,ti)
end if
f%name = "<generated>, grid: " // trim(seed%expr)

elseif (seed%iff == ifformat_copy .or. seed%iff == ifformat_as_lap .or.&
seed%iff == ifformat_as_pot .or. seed%iff == ifformat_as_grad .or. &
elseif (seed%iff == ifformat_copy .or. seed%iff == ifformat_as_ft_x .or.&
seed%iff == ifformat_as_ft_y .or. seed%iff == ifformat_as_ft_z .or. &
seed%iff == ifformat_as_ft_xx .or. seed%iff == ifformat_as_ft_xy .or. &
seed%iff == ifformat_as_ft_xz .or. seed%iff == ifformat_as_ft_yy .or. &
seed%iff == ifformat_as_ft_yz .or. seed%iff == ifformat_as_ft_zz .or. &
seed%iff == ifformat_as_ft_grad .or. seed%iff == ifformat_as_ft_lap .or. &
seed%iff == ifformat_as_ft_pot .or.&
seed%iff == ifformat_as_clm .or. seed%iff == ifformat_as_clm_sub .or.&
seed%iff == ifformat_as_resample) then
errmsg = "error in file format for field_new"
Expand Down Expand Up @@ -686,8 +693,10 @@ module subroutine load_as_fftgrid(f,c,id,name,g,ityp,isry_,n)
use grid3mod, only: grid3
use fragmentmod, only: fragment
use tools_io, only: ferror, faterr
use param, only: ifformat_as_lap, ifformat_as_grad, ifformat_as_pot,&
ifformat_as_hxx1, ifformat_as_hxx2, ifformat_as_hxx3, ifformat_as_resample
use param, only: ifformat_as_ft_x,ifformat_as_ft_y,ifformat_as_ft_z,ifformat_as_ft_xx,&
ifformat_as_ft_xy,ifformat_as_ft_xz,ifformat_as_ft_yy,ifformat_as_ft_yz,&
ifformat_as_ft_zz,ifformat_as_ft_grad,ifformat_as_ft_lap,ifformat_as_ft_pot,&
ifformat_as_resample
class(field), intent(inout) :: f !< Input/output field
type(crystal), intent(in), target :: c
integer, intent(in) :: id
Expand All @@ -712,20 +721,10 @@ module subroutine load_as_fftgrid(f,c,id,name,g,ityp,isry_,n)
f%isinit = .true.
f%type = type_grid
if (.not.allocated(f%grid)) allocate(f%grid)
if (ityp == ifformat_as_lap) then
call f%grid%laplacian_hxx(g,0)
elseif (ityp == ifformat_as_grad) then
call f%grid%gradrho(g)
elseif (ityp == ifformat_as_pot) then
call f%grid%pot(g,isry)
elseif (ityp == ifformat_as_hxx1) then
call f%grid%laplacian_hxx(g,1)
elseif (ityp == ifformat_as_hxx2) then
call f%grid%laplacian_hxx(g,2)
elseif (ityp == ifformat_as_hxx3) then
call f%grid%laplacian_hxx(g,3)
elseif (ityp == ifformat_as_resample) then
if (ityp == ifformat_as_resample) then
call f%grid%resample(g,n)
else
call f%grid%fft(g,ityp)
end if
f%numerical = .false.
f%exact = .false.
Expand Down
46 changes: 34 additions & 12 deletions src/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ module subroutine fieldseed_parse(f,line,withoptions,lp0)
ifformat_vasp, ifformat_vaspnov, ifformat_qub, ifformat_xsf, ifformat_elkgrid,&
ifformat_siestagrid, ifformat_fplogrid, ifformat_dftb, ifformat_pwc,&
ifformat_wfn, ifformat_wfx, ifformat_fchk,&
ifformat_molden, ifformat_as, ifformat_as_promolecular, ifformat_as_core, ifformat_as_lap,&
ifformat_as_resample,&
ifformat_as_grad, ifformat_as_pot, ifformat_as_clm, ifformat_as_clm_sub, ifformat_copy, &
ifformat_promolecular, ifformat_promolecular_fragment, ifformat_as_ghost
ifformat_molden, ifformat_as, ifformat_as_promolecular, ifformat_as_core,&
ifformat_as_resample, ifformat_as_clm, ifformat_as_clm_sub, ifformat_copy,&
ifformat_promolecular, ifformat_promolecular_fragment, ifformat_as_ghost,&
ifformat_as_ft_x, ifformat_as_ft_y, ifformat_as_ft_z, ifformat_as_ft_xx,&
ifformat_as_ft_xy, ifformat_as_ft_xz, ifformat_as_ft_yy, ifformat_as_ft_yz,&
ifformat_as_ft_zz, ifformat_as_ft_grad, ifformat_as_ft_lap, ifformat_as_ft_pot

class(fieldseed), intent(inout) :: f
character*(*) :: line
logical, intent(in) :: withoptions
Expand Down Expand Up @@ -323,13 +326,32 @@ module subroutine fieldseed_parse(f,line,withoptions,lp0)
return
end if
end if
elseif (equal(lword,"lap") .or. equal(lword,"grad") .or. equal(lword,"pot")) then
if (equal(lword,"lap")) then
f%iff = ifformat_as_lap
elseif (equal(lword,"grad")) then
f%iff = ifformat_as_grad
else
f%iff = ifformat_as_pot
elseif (equal(lword,"fft")) then
call read_next_as_word()
if (equal(lword,"gx")) then
f%iff = ifformat_as_ft_x
elseif (equal(lword,"gy")) then
f%iff = ifformat_as_ft_y
elseif (equal(lword,"gz")) then
f%iff = ifformat_as_ft_z
elseif (equal(lword,"hxx")) then
f%iff = ifformat_as_ft_xx
elseif (equal(lword,"hxy")) then
f%iff = ifformat_as_ft_xy
elseif (equal(lword,"hxz")) then
f%iff = ifformat_as_ft_xz
elseif (equal(lword,"hyy")) then
f%iff = ifformat_as_ft_yy
elseif (equal(lword,"hyz")) then
f%iff = ifformat_as_ft_yz
elseif (equal(lword,"hzz")) then
f%iff = ifformat_as_ft_zz
elseif (equal(lword,"gmod")) then
f%iff = ifformat_as_ft_grad
elseif (equal(lword,"lap")) then
f%iff = ifformat_as_ft_lap
elseif (equal(lword,"pot")) then
f%iff = ifformat_as_ft_pot
end if
call read_next_as_word()
if (len_trim(word) < 1) then
Expand All @@ -338,7 +360,7 @@ module subroutine fieldseed_parse(f,line,withoptions,lp0)
return
end if
f%ids = word
if (f%iff == ifformat_as_pot) then
if (f%iff == ifformat_as_ft_pot) then
call read_next_as_word()
if (equal(lword,"ry") .or. equal(lword,"rydberg")) then
f%isry = .true.
Expand Down
23 changes: 6 additions & 17 deletions src/grid3mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ module grid3mod
procedure :: read_wannier_chk !< qe/wannier info from chk file
procedure :: interp !< interpolate the grid at an arbitrary point
procedure :: grinterp_smr !< interpolate with the smoothrho method
procedure :: laplacian_hxx !< grid3 as the Laplacian or Hessian diagonal of another grid3
procedure :: pot !< grid3 as the potential generated by another grid3
procedure :: gradrho !< grid3 as the gradrho of another grid3
procedure :: fft !< grid3 as the FFT of another grid3
procedure :: resample !< grid3 as a Fourier resampling of another grid3
procedure :: rotate_qe_evc !< write U-rotated scratch files using QE evc file
procedure :: get_qe_wnr !< build a Wannier function from Bloch coeffs (pre-open, parallel)
Expand Down Expand Up @@ -260,20 +258,11 @@ module subroutine grinterp_smr(f,xi,y,yp,ypp)
real*8, intent(out) :: yp(3) !< First derivative
real*8, intent(out) :: ypp(3,3) !< Second derivative
end subroutine grinterp_smr
module subroutine laplacian_hxx(flap,frho,ix)
class(grid3), intent(inout) :: flap
type(grid3), intent(in) :: frho
integer, intent(in) :: ix
end subroutine laplacian_hxx
module subroutine gradrho(fgrho,frho)
class(grid3), intent(inout) :: fgrho
type(grid3), intent(in) :: frho
end subroutine gradrho
module subroutine pot(fpot,frho,isry)
class(grid3), intent(inout) :: fpot
type(grid3), intent(in) :: frho
logical, intent(in) :: isry
end subroutine pot
module subroutine fft(fnew,fold,iff)
class(grid3), intent(inout) :: fnew
type(grid3), intent(in) :: fold
integer, intent(in) :: iff
end subroutine fft
module subroutine resample(frs,frho,n2)
class(grid3), intent(inout) :: frs
type(grid3), intent(in) :: frho
Expand Down
Loading

0 comments on commit fcd1133

Please sign in to comment.