Streamer fluid modeling - An overview of ARCoS  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
dft.c File Reference

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"
Include dependency graph for dft.c:

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.
 

Detailed Description

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

  1. If we decide to change our FFT library, we only have to make changes in this module.
  2. We can compile a 2d version of the code that does not depend on fftw. by eliminating this module.

Definition in file dft.c.

Macro Definition Documentation

#define AM   (1.0 / RAND_MAX)

Definition at line 366 of file dft.c.

Function Documentation

static void renormalize ( cdr_grid_t grid,
rz_array_t var 
)
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.

Here is the caller graph for this function:

static double rnd_gauss ( double  mu,
double  sigma 
)
static

Returns a random number with a gaussian distribution centered around mu with width sigma.

Definition at line 339 of file dft.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static double ranf ( void  )
static

Returns a random number uniformly distributed in [0, 1].

Definition at line 370 of file dft.c.

Here is the caller graph for this function:

void dft_transform ( rz_array_t in,
rz_array_t out,
int  sign 
)

Transform the discrete fourier transformations ????

Definition at line 37 of file dft.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void dft_diff ( grid_t grid,
rz_array_t f 
)

Calculates the Fourier transform of the derivative of a function given its Fourier transform.

Definition at line 97 of file dft.c.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

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.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

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.

Definition at line 270 of file dft.c.

Here is the call graph for this function:

Here is the caller graph for this function: