HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
FPPowerSystem1BusComputeDiffNumber.c File Reference
#include <stdlib.h>
#include <basic.h>
#include <mathfunctions.h>
#include <arrayfunctions.h>
#include <physicalmodels/fppowersystem1bus.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

double FPPowerSystem1BusDissipationFunction (int, int, void *, double)
 
double FPPowerSystem1BusComputeDiffNumber (void *s, void *m, double dt, double t)
 

Function Documentation

◆ FPPowerSystem1BusDissipationFunction()

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

◆ FPPowerSystem1BusComputeDiffNumber()

double FPPowerSystem1BusComputeDiffNumber ( void *  s,
void *  m,
double  dt,
double  t 
)

Definition at line 11 of file FPPowerSystem1BusComputeDiffNumber.c.

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 absolute(a)
Definition: math_ops.h:32
double FPPowerSystem1BusDissipationFunction(int, int, void *, double)
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _YDIR_
Definition: euler2d.h:41
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
int ghosts
Definition: hypar.h:52
double * dxinv
Definition: hypar.h:110