HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FPPowerSystem3BusComputeDiffNumber.c File Reference

Function to compute the maximum diffusion number. More...

#include <stdlib.h>
#include <basic.h>
#include <mathfunctions.h>
#include <arrayfunctions.h>
#include <physicalmodels/fppowersystem3bus.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

int FPPowerSystem3BusDissipationFunction (int, int, void *, double, double *)
 
double FPPowerSystem3BusComputeDiffNumber (void *s, void *m, double dt, double t)
 

Detailed Description

Function to compute the maximum diffusion number.

Author
Debojyoti Ghosh

Definition in file FPPowerSystem3BusComputeDiffNumber.c.

Function Documentation

int FPPowerSystem3BusDissipationFunction ( int  dir1,
int  dir2,
void *  p,
double  t,
double *  dissp 
)

Compute the dissipation coefficient for the 3-bus power system

Parameters
dir1First spatial dimension for the dissipation coefficient
dir2Second spatial dimension for the dissipation coefficient
pObject of type FPPowerSystem3Bus
tCurrent simulation time
disspMatrix of size ndims*ndims to hold the dissipation coefficients (row-major format)

Definition at line 117 of file FPPowerSystem3BusFunctions.c.

125 {
126  FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) p;
128 
129  double sigma11 = params->sigma[0][0];
130  double sigma12 = params->sigma[0][1];
131  double sigma21 = params->sigma[1][0];
132  double sigma22 = params->sigma[1][1];
133 
134  double lambda11 = params->lambda[0][0];
135  double lambda12 = params->lambda[0][1];
136  double lambda21 = params->lambda[1][0];
137  double lambda22 = params->lambda[1][1];
138 
139  double gamma = params->gamma;
140  double omegaB = params->omegaB;
141 
142 #if 0
143  /* steady state coefficients */
144  dissp[2*_MODEL_NDIMS_+0] = sigma11*sigma11*lambda11*lambda11*omegaB;
145  dissp[2*_MODEL_NDIMS_+1] = sigma12*sigma12*lambda12*lambda12*omegaB;
146  dissp[3*_MODEL_NDIMS_+0] = sigma21*sigma21*lambda21*lambda21*omegaB;
147  dissp[3*_MODEL_NDIMS_+1] = sigma22*sigma22*lambda22*lambda22*omegaB;
148 
149  dissp[2*_MODEL_NDIMS_+2] = sigma11*sigma11*lambda11*(1.0-gamma*lambda11);
150  dissp[2*_MODEL_NDIMS_+3] = sigma12*sigma12*lambda12*(1.0-gamma*lambda12);
151  dissp[3*_MODEL_NDIMS_+2] = sigma21*sigma21*lambda21*(1.0-gamma*lambda21);
152  dissp[3*_MODEL_NDIMS_+3] = sigma22*sigma22*lambda22*(1.0-gamma*lambda22);
153 #endif
154 
155  /* time-dependent coefficients */
156  dissp[2*_MODEL_NDIMS_+0] = sigma11*sigma11*lambda11*omegaB*(lambda11*(1-exp(-t/lambda11))-t*exp(-t/lambda11));
157  dissp[2*_MODEL_NDIMS_+1] = sigma12*sigma12*lambda12*omegaB*(lambda12*(1-exp(-t/lambda12))-t*exp(-t/lambda12));
158  dissp[3*_MODEL_NDIMS_+0] = sigma21*sigma21*lambda21*omegaB*(lambda21*(1-exp(-t/lambda21))-t*exp(-t/lambda21));
159  dissp[3*_MODEL_NDIMS_+1] = sigma22*sigma22*lambda22*omegaB*(lambda22*(1-exp(-t/lambda22))-t*exp(-t/lambda22));
160 
161  dissp[2*_MODEL_NDIMS_+2] = sigma11*sigma11*(lambda11*(1-exp(-t/lambda11))+gamma*lambda11*(t*exp(-t/lambda11)-lambda11*(1-exp(-t/lambda11))));
162  dissp[2*_MODEL_NDIMS_+3] = sigma12*sigma12*(lambda12*(1-exp(-t/lambda12))+gamma*lambda12*(t*exp(-t/lambda12)-lambda12*(1-exp(-t/lambda12))));
163  dissp[3*_MODEL_NDIMS_+2] = sigma21*sigma21*(lambda21*(1-exp(-t/lambda21))+gamma*lambda21*(t*exp(-t/lambda21)-lambda21*(1-exp(-t/lambda21))));
164  dissp[3*_MODEL_NDIMS_+3] = sigma22*sigma22*(lambda22*(1-exp(-t/lambda22))+gamma*lambda22*(t*exp(-t/lambda22)-lambda22*(1-exp(-t/lambda22))));
165 
166  return(0);
167 }
#define _ArraySetValue_(x, size, value)
#define _MODEL_NDIMS_
Definition: euler1d.h:56
Structure containing variable and parameters specific to the 3-bus power system model. This structure contains the physical parameters and variables for the Fokker-Planck model for a 3-bus power system.
double FPPowerSystem3BusComputeDiffNumber ( void *  s,
void *  m,
double  dt,
double  t 
)

Computes the maximum diffusion number over the domain. Note that the diffusion is computed over the local domain on this processor only.

Parameters
sSolver object of type HyPar
mMPI object of type MPIVariables
dtTime step size for which to compute the CFL
tTime

Definition at line 19 of file FPPowerSystem3BusComputeDiffNumber.c.

25 {
26  HyPar *solver = (HyPar*) s;
27  FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) solver->physics;
28 
29  int ndims = solver->ndims;
30  int ghosts = solver->ghosts;
31  int *dim = solver->dim_local;
32 
33  double max_diff = 0;
34  int index[ndims];
35  int done = 0; _ArraySetValue_(index,ndims,0);
36  while (!done) {
37  double dxinv[ndims],dissp[ndims*ndims];
38  _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv[0]);
39  _GetCoordinate_(1,index[1],dim,ghosts,solver->dxinv,dxinv[1]);
40  _GetCoordinate_(2,index[2],dim,ghosts,solver->dxinv,dxinv[2]);
41  _GetCoordinate_(3,index[3],dim,ghosts,solver->dxinv,dxinv[3]);
42  FPPowerSystem3BusDissipationFunction(0,0,params,t,dissp);
43 
44  double local_diff[ndims];
45  local_diff[0] = absolute(dissp[0*ndims+0]) * dt * dxinv[0] * dxinv[0];
46  local_diff[1] = absolute(dissp[1*ndims+1]) * dt * dxinv[1] * dxinv[1];
47  local_diff[2] = absolute(dissp[2*ndims+2]) * dt * dxinv[2] * dxinv[2];
48  local_diff[3] = absolute(dissp[3*ndims+3]) * dt * dxinv[3] * dxinv[3];
49 
50  if (local_diff[0] > max_diff) max_diff = local_diff[0];
51  if (local_diff[1] > max_diff) max_diff = local_diff[1];
52  if (local_diff[2] > max_diff) max_diff = local_diff[2];
53  if (local_diff[3] > max_diff) max_diff = local_diff[3];
54 
55  _ArrayIncrementIndex_(ndims,dim,index,done);
56  }
57 
58  return(max_diff);
59 }
int FPPowerSystem3BusDissipationFunction(int, int, void *, double, double *)
#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
Structure containing variable and parameters specific to the 3-bus power system model. This structure contains the physical parameters and variables for the Fokker-Planck model for a 3-bus power system.
double * dxinv
Definition: hypar.h:110
int ndims
Definition: hypar.h:26
#define absolute(a)
Definition: math_ops.h:32
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23