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

Compute the dissipative term for the FPPowerSystem3Bus system. More...

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

Go to the source code of this file.

Functions

int FPPowerSystem3BusDissipationFunction (int, int, void *, double, double *)
 
int FPPowerSystem3BusDiffusion (double *f, double *u, int dir1, int dir2, void *s, double t)
 

Detailed Description

Compute the dissipative term for the FPPowerSystem3Bus system.

Author
Debojyoti Ghosh

Definition in file FPPowerSystem3BusDiffusion.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.
int FPPowerSystem3BusDiffusion ( double *  f,
double *  u,
int  dir1,
int  dir2,
void *  s,
double  t 
)

Compute the dissipation term for the FPPowerSystem3Bus system

Parameters
fArray to hold the computed dissipation term vector (same layout as u)
uArray with the solution vector
dir1First spatial dimension for the dissipation term being computed
dir2Second spatial dimension for the dissipation term being computed
sSolver object of type HyPar
tCurrent simulation time

Definition at line 15 of file FPPowerSystem3BusDiffusion.c.

23 {
24  HyPar *solver = (HyPar*) s;
25  FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) solver->physics;
26  int i, v;
27 
28  int *dim = solver->dim_local;
29  int ghosts = solver->ghosts;
30  static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_];
31  static double dissipation[_MODEL_NDIMS_*_MODEL_NDIMS_];
32 
33  /* set bounds for array index to include ghost points */
34  _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_);
35  for (i=0; i<_MODEL_NDIMS_; i++) bounds[i] += 2*ghosts;
36 
37  /* set offset such that index is compatible with ghost point arrangement */
38  _ArraySetValue_(offset,_MODEL_NDIMS_,-ghosts);
39 
40  int done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0);
41  while (!done) {
42  int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p);
43  FPPowerSystem3BusDissipationFunction(dir1,dir2,params,t,dissipation);
44  for (v = 0; v < _MODEL_NVARS_; v++) f[_MODEL_NVARS_*p+v] = dissipation[dir1*_MODEL_NDIMS_+dir2] * u[_MODEL_NVARS_*p+v];
45  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done);
46  }
47 
48  return(0);
49 }
int FPPowerSystem3BusDissipationFunction(int, int, void *, double, double *)
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _MODEL_NVARS_
Definition: euler1d.h:58
void * physics
Definition: hypar.h:266
int * dim_local
Definition: hypar.h:37
#define _MODEL_NDIMS_
Definition: euler1d.h:56
int ghosts
Definition: hypar.h:52
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArrayCopy1D_(x, y, size)
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.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23