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

3-Bus Power System model More...

Go to the source code of this file.

Data Structures

struct  FPPowerSystem3Bus
 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. More...
 

Macros

#define _FP_POWER_SYSTEM_3BUS_   "fp-power-system-3bus"
 
#define _MODEL_NDIMS_   4
 
#define _MODEL_NVARS_   1
 

Functions

int FPPowerSystem3BusInitialize (void *, void *)
 
int FPPowerSystem3BusCleanup (void *)
 

Detailed Description

3-Bus Power System model

Author
Debojyoti Ghosh

Fokker-Planck model for a 3-Bus power system: This model governs the dynamics of an electrical system with three generators. The third generator is the reference generator and the state of the other two generators are defined with respect to the state of the third generator. \(p\left({\bf x}\right)\) is the probability density function (PDF), governed by the following advection-diffusion equation:

\begin{equation} \frac{\partial p}{\partial t} + \nabla_{\bf x} \cdot \left(\left<{\bf v}\right> p\right) = \nabla_{\bf x} \cdot \left( {\bf D} \nabla_{\bf x} p \right), \end{equation}

where

\begin{align} {\bf x} &= \left[ \theta_1, \theta_2, \omega_1, \omega_2 \right]^T, \\ \left<{\bf v}\right> &= \left[ \omega_B\omega_1, \omega_B\omega_2, F_1-\gamma\omega_1-S_1, F_2-\gamma\omega_2-S_2 \right]^T \\ {\bf D} &= \left[ \begin{array}{cc} {\bf 0}_N & {\bf 0}_N \\ {\bf D}^\theta_N & {\bf D}^\omega_N \end{array} \right] \end{align}

The parameters for the system are:

\begin{align} N&=2,\\ D_{ij}^\omega &= \sigma_{ij}^2\lambda_{ij}\left(1-\gamma\lambda_{ij}\right), \\ D_{ij}^\theta &= \sigma_{ij}^2\lambda_{ij}^2\omega_B, \\ F_i &= \frac{1}{2H_i} \left<P^m_i\right> - \frac{1}{2H_{ref}}\left<P_{ref}^m\right>, \\ S_i &= \frac{1}{2H_i} P^e_i - \frac{1}{2H_{ref}} P_{ref}^e, \\ P_i^e &= \mathcal{R}\left\{ E_i \sum_{k=1}^{N+1} E_k^* \left( Y^* \right)_{ik} \right\}, Y = G+iB \end{align}

where \(*\) denotes the complex conjugate.

Reference: To be added soon.

Definition in file fppowersystem3bus.h.


Data Structure Documentation

struct FPPowerSystem3Bus

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.

Definition at line 49 of file fppowersystem3bus.h.

Data Fields
int N

Number indepedent buses in power system (excluding reference bus) (must be 2)

double Pm1_avg

Average mechanical power of generator 1 \(\left< P^m_1\right>\)

double Pm2_avg

Average mechanical power of generator 2 \(\left< P^m_2\right>\)

double Pmref_avg

Average mechanical power of generator 3 (reference) \(\left< P^m_{ref}\right>\)

double H1

Inertia of generator 1 \( H_1 \)

double H2

Inertia of generator 2 \( H_2 \)

double Href

Inertia of generator 3 (reference) \( H_{ref} \)

double E1

Internal emf phasor for generator 1 \( E_1 \)

double E2

Internal emf phasor for generator 2 \( E_2 \)

double Eref

Internal emf phasor for generator 3 (reference) \( E_{ref} \)

double omegaB

Rotor base angular frequency \(\omega_B\)

double sigma[2][2]

Covariance matrix \(\sigma\)

double lambda[2][2]

Correlation time \(\lambda\)

double gamma

Damping rate \( \gamma \)

double * G

Conductance matrix \( G \)

double * B

Susceptance matrix \( B \)

double pdf_integral

Integral of the probability density function over the domain

Macro Definition Documentation

#define _FP_POWER_SYSTEM_3BUS_   "fp-power-system-3bus"

Fokker-Planck model for 3-Bus power system

Definition at line 30 of file fppowersystem3bus.h.

#define _MODEL_NDIMS_   4

Number of spatial dimensions

Definition at line 36 of file fppowersystem3bus.h.

#define _MODEL_NVARS_   1

Number of variables per grid point

Definition at line 38 of file fppowersystem3bus.h.

Function Documentation

int FPPowerSystem3BusInitialize ( void *  s,
void *  m 
)

Initialize the 3-bus power system model: Sets the default parameters, read in and set physics-related parameters, and set the physics-related function pointers in HyPar.

Parameters
sSolver object of type HyPar
mMPI object of type MPIVariables

Definition at line 27 of file FPPowerSystem3BusInitialize.c.

31 {
32  HyPar *solver = (HyPar*) s;
33  MPIVariables *mpi = (MPIVariables*) m;
34  FPPowerSystem3Bus *physics = (FPPowerSystem3Bus*) solver->physics;
35  int ferr, N;
37 
38  static int count = 0;
39 
40  if (solver->nvars != _MODEL_NVARS_) {
41  fprintf(stderr,"Error in FPPowerSystem3BusInitialize(): nvars has to be %d.\n",_MODEL_NVARS_);
42  return(1);
43  }
44  if (solver->ndims != _MODEL_NDIMS_) {
45  fprintf(stderr,"Error in FPPowerSystem3BusInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_);
46  return(1);
47  }
48 
49  double pi = 4.0*atan(1.0);
50  /* default values of model parameters */
51  physics->N = 2;
52  physics->Pm1_avg = 0.8;
53  physics->Pm2_avg = 1.6;
54  physics->Pmref_avg = 0.79330781761651;
55  physics->H1 = 3.20;
56  physics->H2 = 6.40;
57  physics->Href = 13.60;
58  physics->E1 = 1.01556070860155;
59  physics->E2 = 1.0491099265981;
60  physics->Eref = 1.05623172878954;
61  physics->omegaB = 2*pi*60.0;
62  physics->sigma[0][0] = 0.0125;
63  physics->sigma[0][1] = 0.0;
64  physics->sigma[1][0] = 0.0;
65  physics->sigma[1][1] = 0.0125;
66  physics->lambda[0][0] = 10.0/physics->omegaB;
67  physics->lambda[0][1] = 0.0;
68  physics->lambda[1][0] = 0.0;
69  physics->lambda[1][1] = 10.0/physics->omegaB;
70  physics->gamma = 0.25;
71 
72  physics->G = (double*) calloc (3*3,sizeof(double));
73  physics->B = (double*) calloc (3*3,sizeof(double));
74 
75  physics->G[0*3+0] = 0.276805493111691;
76  physics->G[0*3+1] = 0.213024867595501;
77  physics->G[0*3+2] = 0.209205876527443;
78  physics->G[1*3+0] = 0.213024867595501;
79  physics->G[1*3+1] = 0.419642083051144;
80  physics->G[1*3+2] = 0.286592141665043;
81  physics->G[2*3+0] = 0.209205876527443;
82  physics->G[2*3+1] = 0.286592141665044;
83  physics->G[2*3+2] = 0.844559256324453;
84 
85  physics->B[0*3+0] = -2.36794416971567;
86  physics->B[0*3+1] = 1.08817493992579;
87  physics->B[0*3+2] = 1.22601259339234;
88  physics->B[1*3+0] = 1.08817493992579;
89  physics->B[1*3+1] = -2.72352378723346;
90  physics->B[1*3+2] = 1.51348094527252;
91  physics->B[2*3+0] = 1.22601259339234;
92  physics->B[2*3+1] = 1.51348094527252;
93  physics->B[2*3+2] = -2.98729895217208;
94 
95  /* reading physical model specific inputs - all processes */
96  FILE *in;
97  if ((!mpi->rank) && (!count)) printf("Reading physical model inputs from file \"physics.inp\".\n");
98  in = fopen("physics.inp","r");
99  if (!in) {
100  if (!mpi->rank) fprintf(stderr,"Error: File \"physics.inp\" not found.\n");
101  return(1);
102  } else {
103  char word[_MAX_STRING_SIZE_];
104  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
105  if (!strcmp(word, "begin")){
106  while (strcmp(word, "end")){
107  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
108  if (!strcmp(word,"Pm1_avg" )) {ferr=fscanf(in,"%lf",&physics->Pm1_avg ) ;if(ferr!=1)return(1);}
109  else if (!strcmp(word,"Pm2_avg" )) {ferr=fscanf(in,"%lf",&physics->Pm2_avg ) ;if(ferr!=1)return(1);}
110  else if (!strcmp(word,"Pmref_avg" )) {ferr=fscanf(in,"%lf",&physics->Pmref_avg ) ;if(ferr!=1)return(1);}
111  else if (!strcmp(word,"H1" )) {ferr=fscanf(in,"%lf",&physics->H1 ) ;if(ferr!=1)return(1);}
112  else if (!strcmp(word,"H2" )) {ferr=fscanf(in,"%lf",&physics->H2 ) ;if(ferr!=1)return(1);}
113  else if (!strcmp(word,"Href" )) {ferr=fscanf(in,"%lf",&physics->Href ) ;if(ferr!=1)return(1);}
114  else if (!strcmp(word,"E1" )) {ferr=fscanf(in,"%lf",&physics->E1 ) ;if(ferr!=1)return(1);}
115  else if (!strcmp(word,"E2" )) {ferr=fscanf(in,"%lf",&physics->E2 ) ;if(ferr!=1)return(1);}
116  else if (!strcmp(word,"Eref" )) {ferr=fscanf(in,"%lf",&physics->Eref ) ;if(ferr!=1)return(1);}
117  else if (!strcmp(word,"omegaB" )) {ferr=fscanf(in,"%lf",&physics->omegaB ) ;if(ferr!=1)return(1);}
118  else if (!strcmp(word,"gamma" )) {ferr=fscanf(in,"%lf",&physics->gamma ) ;if(ferr!=1)return(1);}
119  else if (!strcmp(word,"sigma" )) {
120  ferr=fscanf(in,"%lf",&physics->sigma[0][0]) ;if(ferr!=1)return(1);
121  ferr=fscanf(in,"%lf",&physics->sigma[0][1]) ;if(ferr!=1)return(1);
122  ferr=fscanf(in,"%lf",&physics->sigma[1][0]) ;if(ferr!=1)return(1);
123  ferr=fscanf(in,"%lf",&physics->sigma[1][1]) ;if(ferr!=1)return(1);
124  } else if (!strcmp(word,"lambda")) {
125  ferr=fscanf(in,"%lf",&physics->lambda[0][0]) ;if(ferr!=1)return(1);
126  ferr=fscanf(in,"%lf",&physics->lambda[0][1]) ;if(ferr!=1)return(1);
127  ferr=fscanf(in,"%lf",&physics->lambda[1][0]) ;if(ferr!=1)return(1);
128  ferr=fscanf(in,"%lf",&physics->lambda[1][1]) ;if(ferr!=1)return(1);
129  } else if (!strcmp(word,"G")) {
130  ferr=fscanf(in,"%lf",&physics->G[0*3+0]) ;if(ferr!=1)return(1);
131  ferr=fscanf(in,"%lf",&physics->G[0*3+1]) ;if(ferr!=1)return(1);
132  ferr=fscanf(in,"%lf",&physics->G[0*3+2]) ;if(ferr!=1)return(1);
133  ferr=fscanf(in,"%lf",&physics->G[1*3+0]) ;if(ferr!=1)return(1);
134  ferr=fscanf(in,"%lf",&physics->G[1*3+1]) ;if(ferr!=1)return(1);
135  ferr=fscanf(in,"%lf",&physics->G[1*3+2]) ;if(ferr!=1)return(1);
136  ferr=fscanf(in,"%lf",&physics->G[2*3+0]) ;if(ferr!=1)return(1);
137  ferr=fscanf(in,"%lf",&physics->G[2*3+1]) ;if(ferr!=1)return(1);
138  ferr=fscanf(in,"%lf",&physics->G[2*3+2]) ;if(ferr!=1)return(1);
139  } else if (!strcmp(word,"B")) {
140  ferr=fscanf(in,"%lf",&physics->B[0*3+0]) ;if(ferr!=1)return(1);
141  ferr=fscanf(in,"%lf",&physics->B[0*3+1]) ;if(ferr!=1)return(1);
142  ferr=fscanf(in,"%lf",&physics->B[0*3+2]) ;if(ferr!=1)return(1);
143  ferr=fscanf(in,"%lf",&physics->B[1*3+0]) ;if(ferr!=1)return(1);
144  ferr=fscanf(in,"%lf",&physics->B[1*3+1]) ;if(ferr!=1)return(1);
145  ferr=fscanf(in,"%lf",&physics->B[1*3+2]) ;if(ferr!=1)return(1);
146  ferr=fscanf(in,"%lf",&physics->B[2*3+0]) ;if(ferr!=1)return(1);
147  ferr=fscanf(in,"%lf",&physics->B[2*3+1]) ;if(ferr!=1)return(1);
148  ferr=fscanf(in,"%lf",&physics->B[2*3+2]) ;if(ferr!=1)return(1);
149  }
150  }
151  } else {
152  if (!mpi->rank) fprintf(stderr,"Error: Illegal format in file \"physics.inp\".\n");
153  return(1);
154  }
155  }
156  fclose(in);
157 
158  if (!strcmp(solver->SplitHyperbolicFlux,"yes")) {
159  if (!mpi->rank) {
160  fprintf(stderr,"Error in FPPowerSystem3BusInitialize: This physical model does not have a splitting ");
161  fprintf(stderr,"of the hyperbolic term defined.\n");
162  }
163  return(1);
164  }
165 
166  /* initializing physical model-specific functions */
172 
173  count++;
174  return(0);
175 }
double(* ComputeCFL)(void *, void *, double, double)
Definition: hypar.h:269
#define _MODEL_NVARS_
Definition: euler1d.h:58
int(* HFunction)(double *, double *, int, int, void *, double)
Definition: hypar.h:313
void * physics
Definition: hypar.h:266
int(* Upwind)(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: hypar.h:295
int(* FFunction)(double *, double *, int, void *, double)
Definition: hypar.h:276
#define _MODEL_NDIMS_
Definition: euler1d.h:56
int FPPowerSystem3BusDiffusion(double *f, double *u, int dir1, int dir2, void *s, double t)
int FPPowerSystem3BusUpwind(double *, double *, double *, double *, double *, double *, int, void *, double)
#define _MAX_STRING_SIZE_
Definition: basic.h:14
double FPPowerSystem3BusComputeCFL(void *s, void *m, double dt, double t)
double(* ComputeDiffNumber)(void *, void *, double, double)
Definition: hypar.h:272
int FPPowerSystem3BusAdvection(double *f, double *u, int dir, void *s, double t)
int nvars
Definition: hypar.h:29
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.
char SplitHyperbolicFlux[_MAX_STRING_SIZE_]
Definition: hypar.h:92
int ndims
Definition: hypar.h:26
double FPPowerSystem3BusComputeDiffNumber(void *s, void *m, double dt, double t)
Structure of MPI-related variables.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _DECLARE_IERR_
Definition: basic.h:17
int FPPowerSystem3BusCleanup ( void *  s)

Clean up allocations in the FPPowerSystem3Bus system

Parameters
sObject of type FPPowerSystem3Bus

Definition at line 10 of file FPPowerSystem3BusCleanup.c.

13 {
14  FPPowerSystem3Bus *physics = (FPPowerSystem3Bus*) s;
15  free(physics->G);
16  free(physics->B);
17  return(0);
18 }
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.