HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FPPowerSystem1BusComputeCFL.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 FPPowerSystem1BusDriftFunction (int, void *, double, double, double)
 
double FPPowerSystem1BusComputeCFL (void *s, void *m, double dt, double t)
 

Function Documentation

double FPPowerSystem1BusDriftFunction ( int  ,
void *  ,
double  ,
double  ,
double   
)

Definition at line 4 of file FPPowerSystem1BusFunctions.c.

5 {
7 
8  double drift = 0;
9  if (dir == _XDIR_) {
10  drift = params->omegaB * (y - params->omegaS);
11  } else if (dir == _YDIR_) {
12  drift = (params->omegaS/(2*params->H))
13  * (params->Pm_avg - params->Pmax*sin(x) - params->D*(y-params->omegaS));
14  }
15 
16  return drift;
17 }
#define _YDIR_
Definition: euler2d.h:41
#define drift(x)
Definition: fpdoublewell.h:31
#define _XDIR_
Definition: euler1d.h:75
double FPPowerSystem1BusComputeCFL ( void *  s,
void *  m,
double  dt,
double  t 
)

Definition at line 11 of file FPPowerSystem1BusComputeCFL.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_cfl = 0;
21  int index[ndims];
22  int done = 0; _ArraySetValue_(index,ndims,0);
23  while (!done) {
24  double x; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->x,x);
25  double y; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->x,y);
26  double dxinv; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv);
27  double dyinv; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv);
28  double drift_x= FPPowerSystem1BusDriftFunction(_XDIR_,params,x,y,t);
29  double drift_y= FPPowerSystem1BusDriftFunction(_YDIR_,params,x,y,t);
30 
31  double local_cfl_x = absolute(drift_x) * dt * dxinv;
32  double local_cfl_y = absolute(drift_y) * dt * dyinv;
33 
34  if (local_cfl_x > max_cfl) max_cfl = local_cfl_x;
35  if (local_cfl_y > max_cfl) max_cfl = local_cfl_y;
36 
37  _ArrayIncrementIndex_(ndims,dim,index,done);
38  }
39 
40  return(max_cfl);
41 }
#define _YDIR_
Definition: euler2d.h:41
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int * dim_local
Definition: hypar.h:37
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
int ghosts
Definition: hypar.h:52
double * dxinv
Definition: hypar.h:110
int ndims
Definition: hypar.h:26
#define absolute(a)
Definition: math_ops.h:32
double * x
Definition: hypar.h:107
double FPPowerSystem1BusDriftFunction(int, void *, double, double, double)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _XDIR_
Definition: euler1d.h:75