From density to structure factors using inverse Fourier synthesis
invfousynth.Rd
Given a density as vector calculated in N grid points, the unit cell size and an array of Miller indices hidx, this function calculates amplitudes and phases of the structure factors corresponding to this density, via inverse Fourier transform.
Arguments
- a
A real number. The unit cell side length.
- rho
A vector of N real numbers representing the 1D density at each of the regular N grid point.
- hidx
A vector of integer numbers. The set of 1D Miller indices corresponding to the set of structure factors F, to be calculated.
Value
A vector of N real numbers representing the calculated 1D density at each one of the regular N grid points.
Examples
# First create the crystal structure (in P1)
a <- 10
SG <- "P1"
x0 <- c(1,4,6.5)
Z <- c(8,26,6)
B <- c(18,20,17)
occ <- c(1,1,1)
sdata <- standardise_sdata(a,SG,x0,Z,B,occ)
# 10 Miller indices plus DC component
hidx <- 0:10
# Compute structure factors
ftmp1 <- strufac(hidx,sdata)
# Number of grid points
N <- 1000
# Density
rtmp <- fousynth(a,ftmp1$Fmod,ftmp1$Fpha,hidx,N)
# Using inverse Fourier to obtain structure factors
ftmp2 <- invfousynth(a,rtmp$rr,hidx)
# Comparison
print(abs(ftmp1$Fmod-ftmp2$Fmod))
#> [1] 0.000000e+00 3.552714e-15 1.776357e-15 3.552714e-15 5.329071e-15
#> [6] 4.440892e-16 0.000000e+00 4.440892e-16 1.998401e-15 3.219647e-15
#> [11] 1.318390e-16
print(abs(ftmp1$Fpha-ftmp2$Fpha))
#> [1] 0.000000e+00 0.000000e+00 1.421085e-14 0.000000e+00 0.000000e+00
#> [6] 0.000000e+00 0.000000e+00 0.000000e+00 2.131628e-13 3.552714e-13
#> [11] 0.000000e+00