HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FPPowerSystem1BusComputeDiffNumber.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <basic.h>
3 #include <mathfunctions.h>
4 #include <arrayfunctions.h>
6 #include <mpivars.h>
7 #include <hypar.h>
8 
9 double FPPowerSystem1BusDissipationFunction(int,int,void*,double);
10 
11 double FPPowerSystem1BusComputeDiffNumber(void *s,void *m,double dt,double t)
12 {
13  HyPar *solver = (HyPar*) s;
14  FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics;
15 
16  int ndims = solver->ndims;
17  int ghosts = solver->ghosts;
18  int *dim = solver->dim_local;
19 
20  double max_diff = 0;
21  int index[ndims];
22  int done = 0; _ArraySetValue_(index,ndims,0);
23  while (!done) {
24  double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv);
25  double dyinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->dxinv,dyinv);
26  double dissp_yx= FPPowerSystem1BusDissipationFunction(_YDIR_,_XDIR_,params,t);
27  double dissp_yy= FPPowerSystem1BusDissipationFunction(_YDIR_,_YDIR_,params,t);
28 
29  double local_diff_yx = absolute(dissp_yx) * dt * dyinv * dxinv;
30  double local_diff_yy = absolute(dissp_yy) * dt * dyinv * dyinv;
31 
32  if (local_diff_yx > max_diff) max_diff = local_diff_yx;
33  if (local_diff_yy > max_diff) max_diff = local_diff_yy;
34 
35  _ArrayIncrementIndex_(ndims,dim,index,done);
36  }
37 
38  return(max_diff);
39 }
#define _YDIR_
Definition: euler2d.h:41
#define _ArraySetValue_(x, size, value)
double FPPowerSystem1BusComputeDiffNumber(void *s, void *m, double dt, double t)
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int * dim_local
Definition: hypar.h:37
MPI related function definitions.
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
int ghosts
Definition: hypar.h:52
Contains function definitions for common mathematical functions.
Contains structure definition for hypar.
double * dxinv
Definition: hypar.h:110
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Contains macros and function definitions for common array operations.
#define absolute(a)
Definition: math_ops.h:32
double FPPowerSystem1BusDissipationFunction(int, int, void *, double)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
Fokker-Planck Model for 1-Bus Power System.
#define _XDIR_
Definition: euler1d.h:75