# Read in input data: # fractalD - fractal dimension # rhozero - density scaling parameter # ngrid - Number of grid cells # boxlength - Half length of box in code units (e.g. dimensions (-L,L)) # filename - output filename fractalD, npower, rhozero, seed, ngrid, boxlength, filename = fr.readInputs_Cube() # Define the cubic Grid x,dr = fr.create1DGrid(ngrid,boxlength) # Create Wavenumbers k = fr.constructWavenumbers(ngrid, boxlength, dr) # Compute a 3D power spectrum (power law k^-npower) powerspec = fr.compute1DPowerLawPowerSpectrum(npower, ngrid, k) # The power spectrum has no phase data - must generate it before Fourier Transform # Use random phases to reconstruct the Fourier Transform of the density rho_fft = fr.PowerSpectrumToFT(seed, powerspec) # Compute the inverse fourier transform of rho_fft rho = fr.InverseFFT(rho_fft) # Scale density by rhozero
# fractalD - fractal dimension # rhozero - density scaling parameter # ngrid - Number of grid cells per dimension (i.e. total ngrid^3) # boxlength - Half length of box in code units (e.g. dimensions (-L,L)) # filename - output filename fractalD, npower, deltarho, rhozero, seed, distkey, distunit, masskey, massunit, ngrid, xlength, ylength, zlength, filename = fr.readInputs_Cuboid( ) # Define the cuboid Grid x, y, z, dx, dy, dz = fr.createCuboid(ngrid, ngrid, ngrid, xlength, ylength, zlength, distkey) # Create Wavenumbers kx = fr.constructWavenumbers(ngrid, xlength, dx, distkey) ky = fr.constructWavenumbers(ngrid, ylength, dy, distkey) kz = fr.constructWavenumbers(ngrid, zlength, dz, distkey) # Compute a 3D power spectrum (power law k^-npower) powerspec = fr.computePowerLawPowerSpectrum(npower, ngrid, ngrid, ngrid, kx, ky, kz) # The power spectrum has no phase data - must generate it before Fourier Transform # Use random phases to reconstruct the Fourier Transform of the density rho_fft = fr.PowerSpectrumToFT(seed, powerspec) # Compute the inverse fourier transform of rho_fft rho = fr.InverseFFTN(rho_fft)
print "FRACTAL DENSITY DISTRIBUTION IN A 3D CUBOID" print "-----" # fractalD - fractal dimension # rhozero - density scaling parameter # ngrid - Number of grid cells per dimension (i.e. total ngrid^3) # boxlength - Half length of box in code units (e.g. dimensions (-L,L)) # filename - output filename fractalD, npower, deltarho, rhozero, seed, distkey, distunit, masskey, massunit, ngrid, xlength, ylength, zlength, filename = fr.readInputs_Cuboid() # Define the cuboid Grid x,y,z,dx,dy,dz = fr.createCuboid(ngrid,ngrid,ngrid,xlength,ylength,zlength,distkey) # Create Wavenumbers kx = fr.constructWavenumbers(ngrid, xlength, dx,distkey) ky = fr.constructWavenumbers(ngrid, ylength, dy,distkey) kz = fr.constructWavenumbers(ngrid, zlength, dz,distkey) # Compute a 3D power spectrum (power law k^-npower) powerspec = fr.computePowerLawPowerSpectrum(npower, ngrid, ngrid, ngrid, kx, ky, kz) # The power spectrum has no phase data - must generate it before Fourier Transform # Use random phases to reconstruct the Fourier Transform of the density rho_fft = fr.PowerSpectrumToFT(seed, powerspec) # Compute the inverse fourier transform of rho_fft rho = fr.InverseFFTN(rho_fft)
# Read in input data: # fractalD - fractal dimension # rhozero - density scaling parameter # ngrid - Number of grid cells # boxlength - Half length of box in code units (e.g. dimensions (-L,L)) # filename - output filename fractalD, npower, rhozero, seed, ngrid, boxlength, filename = fr.readInputs_Cube( ) # Define the cubic Grid x, dr = fr.create1DGrid(ngrid, boxlength) # Create Wavenumbers k = fr.constructWavenumbers(ngrid, boxlength, dr) # Compute a 3D power spectrum (power law k^-npower) powerspec = fr.compute1DPowerLawPowerSpectrum(npower, ngrid, k) # The power spectrum has no phase data - must generate it before Fourier Transform # Use random phases to reconstruct the Fourier Transform of the density rho_fft = fr.PowerSpectrumToFT(seed, powerspec) # Compute the inverse fourier transform of rho_fft rho = fr.InverseFFT(rho_fft) # Scale density by rhozero