Streamer fluid modeling - An overview of ARCoS
1.0
|
All routines related with discrete fourier transformations. More...
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fftw3.h>
#include "cdr.h"
#include "cstream.h"
#include "grid.h"
#include "parameters.h"
#include "proto.h"
#include "rz_array.h"
#include "species.h"
Go to the source code of this file.
Macros | |
#define | AM (1.0 / RAND_MAX) |
Functions | |
static void | renormalize (cdr_grid_t *grid, rz_array_t *var) |
Renormalize var for some cases. | |
static double | rnd_gauss (double mu, double sigma) |
Returns a random number with a gaussian distribution centered around mu with width sigma. | |
static double | ranf (void) |
Returns a random number uniformly distributed in [0, 1]. | |
void | dft_transform (rz_array_t *in, rz_array_t *out, int sign) |
Transform the discrete fourier transformations ???? | |
void | dft_diff (grid_t *grid, rz_array_t *f) |
Calculates the Fourier transform of the derivative of a function given its Fourier transform. | |
void | dft_weight (cdr_grid_t *cdr, rz_array_t *var, double weights[], double power) |
Calculates the weight for a given cdr grid and a variable ??? | |
void | dft_out_weights (cdr_grid_t *grid, const char *prefix, double t) |
Outputs to a file 'weights.tsv' the results of dft_weight. | |
void | dft_perturb (cdr_grid_t *cdr, rz_array_t *var, double *epsilon_k) |
Perturbs a FFT-transformed variable. | |
void | dft_dens_perturb_r (cdr_grid_t *grid, int species, double *epsilon_k) |
Takes a density in real space, transforms it to Fourier space, perturbs it and then transforms back to real space. | |
All routines related with discrete fourier transformations.
We make intensive use of the fftw library.
FFTW, the Fastest Fourier Transform in the West, is a collection of fast C routines to compute the discrete Fourier transform. See http://www.fftw.org/doc/ for the manual documents of FFTW version 3.3.3.
Note: All calls to FFTW should be made here, so
Definition in file dft.c.
|
static |
Renormalize var for some cases.
FFTW does not normalize the Fourier transform, so after transforming forth and back, the original values are multiplied by max_ntheta. We use this routine to renormalize var in those cases.
Note that this is taken care of when calculating the charge, so in most cases you do not need to call this function.
Definition at line 319 of file dft.c.
|
static |
|
static |
void dft_transform | ( | rz_array_t * | in, |
rz_array_t * | out, | ||
int | sign | ||
) |
void dft_diff | ( | grid_t * | grid, |
rz_array_t * | f | ||
) |
void dft_weight | ( | cdr_grid_t * | cdr, |
rz_array_t * | var, | ||
double | weights[], | ||
double | power | ||
) |
Calculates the weight for a given cdr grid and a variable ???
For a given cdr grid and a variable, calculates its "weight": the integral of the variable raised to power for each Fourier mode. weights[] must be able to contain at least cdr->ntheta values.
Definition at line 143 of file dft.c.
void dft_out_weights | ( | cdr_grid_t * | grid, |
const char * | prefix, | ||
double | t | ||
) |
Outputs to a file 'weights.tsv' the results of dft_weight.
Assumes that grid->charge is calculated but in real space then it transforms it to Fourier space and leaves it like that: so do not assume that grid->charge is unchanged.
grid->dens[electrons], on the other hand, is transformed forth and back.
Definition at line 177 of file dft.c.
void dft_perturb | ( | cdr_grid_t * | cdr, |
rz_array_t * | var, | ||
double * | epsilon_k | ||
) |
Perturbs a FFT-transformed variable.
Assumes that the unperturbed variable is axi-symmetrical and hence all modes are zero except k=0. The perturbation is then selected as a Gaussian random number epsilon_k times the zero-mode value of the variable. epsilon_k is distributed as epsilon_k = N(0, perturb_epsilon).
Definition at line 246 of file dft.c.
void dft_dens_perturb_r | ( | cdr_grid_t * | grid, |
int | species, | ||
double * | epsilon_k | ||
) |