HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FPPowerSystem1BusDiffusion.c File Reference
#include <stdlib.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <physicalmodels/fppowersystem1bus.h>
#include <hypar.h>

Go to the source code of this file.

Functions

double FPPowerSystem1BusDissipationFunction (int, int, void *, double)
 
int FPPowerSystem1BusDiffusionLaplacian (double *f, double *u, int dir, void *s, double t)
 
int FPPowerSystem1BusDiffusionGeneral (double *f, double *u, int dir1, int dir2, void *s, double t)
 

Function Documentation

double FPPowerSystem1BusDissipationFunction ( int  ,
int  ,
void *  ,
double   
)

Definition at line 19 of file FPPowerSystem1BusFunctions.c.

20 {
21  FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) p;
22 
23  double sigma = params->sigma;
24  double omegaS = params->omegaS;
25  double omegaB = params->omegaB;
26  double lambda = params->lambda;
27  double H = params->H;
28  double D = params->D;
29 
30  double dissp = 0;
31  if (dir1 == _YDIR_) {
32 
33  double term = (sigma*sigma*omegaS*omegaS) / (4.0*H*H);
34  double expterm = exp(-t/lambda);
35 
36  if (dir2 == _XDIR_) {
37  dissp = term * (lambda*omegaB) * (lambda*(1-expterm) - t*expterm);
38  /* dissp = term * lambda*omegaB*lambda; */
39  } else if (dir2 == _YDIR_) {
40  double gamma = D*omegaS / (2.0*H);
41  dissp = term * (lambda*(1-expterm) + (gamma*lambda*(t*expterm-lambda*(1-expterm))) );
42  /* dissp = term * params->lambda * (1 - params->lambda*gamma); */
43  }
44 
45  }
46 
47  return(dissp);
48 }
#define _YDIR_
Definition: euler2d.h:41
#define _XDIR_
Definition: euler1d.h:75
int FPPowerSystem1BusDiffusionLaplacian ( double *  f,
double *  u,
int  dir,
void *  s,
double  t 
)

Definition at line 9 of file FPPowerSystem1BusDiffusion.c.

10 {
11  HyPar *solver = (HyPar*) s;
12  FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics;
13 
14  int *dim = solver->dim_local;
15  int ghosts = solver->ghosts;
16  int ndims = solver->ndims;
17  int nvars = solver->nvars;
18 
19  /* calculate total size of arrays */
20  int bounds[ndims]; _ArrayAddCopy1D_(dim,(2*ghosts),bounds,ndims);
21  int size; _ArrayProduct1D_(bounds,ndims,size); size *= nvars;
22 
23  /* calculate dissipation coefficient -- constant in x and y */
24  double dissipation = FPPowerSystem1BusDissipationFunction(dir,dir,params,t);
25 
26  /* f = dissipation * u */
27  _ArrayScaleCopy1D_(u,dissipation,f,size);
28 
29  return(0);
30 }
#define _ArrayScaleCopy1D_(x, a, y, size)
void * physics
Definition: hypar.h:266
int * dim_local
Definition: hypar.h:37
int ghosts
Definition: hypar.h:52
int nvars
Definition: hypar.h:29
int ndims
Definition: hypar.h:26
#define _ArrayAddCopy1D_(x, a, y, size)
#define _ArrayProduct1D_(x, size, p)
double FPPowerSystem1BusDissipationFunction(int, int, void *, double)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
int FPPowerSystem1BusDiffusionGeneral ( double *  f,
double *  u,
int  dir1,
int  dir2,
void *  s,
double  t 
)

Definition at line 32 of file FPPowerSystem1BusDiffusion.c.

33 {
34  HyPar *solver = (HyPar*) s;
35  FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics;
36 
37  int *dim = solver->dim_local;
38  int ghosts = solver->ghosts;
39  int ndims = solver->ndims;
40  int nvars = solver->nvars;
41 
42  /* calculate total size of arrays */
43  int bounds[ndims]; _ArrayAddCopy1D_(dim,(2*ghosts),bounds,ndims);
44  int size; _ArrayProduct1D_(bounds,ndims,size); size *= nvars;
45 
46  /* calculate dissipation coefficient -- constant in x and y */
47  double dissipation = FPPowerSystem1BusDissipationFunction(dir1,dir2,params,t);
48 
49  /* f = dissipation * u */
50  _ArrayScaleCopy1D_(u,dissipation,f,size);
51 
52  return(0);
53 }
#define _ArrayScaleCopy1D_(x, a, y, size)
void * physics
Definition: hypar.h:266
int * dim_local
Definition: hypar.h:37
int ghosts
Definition: hypar.h:52
int nvars
Definition: hypar.h:29
int ndims
Definition: hypar.h:26
#define _ArrayAddCopy1D_(x, a, y, size)
#define _ArrayProduct1D_(x, size, p)
double FPPowerSystem1BusDissipationFunction(int, int, void *, double)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23