⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1.h

📁 生成导纳矩阵
💻 H
字号:
//complex类定义,用于复数矩阵的运算
class complex
{
public:
 complex(float=0,float=0);
 complex operator+(const complex &) const;
 complex operator-(const complex &) const;
 complex operator*(const complex &) const;
 complex operator/(const complex &) const;
// complex print(complex);
    float real,imag;
};

/////重载构造函数
complex::complex(float re,float im)
{
 this->real=re;
 this->imag=im;
}



/////运算符重载实现函数
complex complex::operator+(const complex &z2) const
{
 complex l(real+z2.real,imag+z2.imag);
 return (l);
}

complex complex::operator-(const complex &z2) const
{
 complex l(real-z2.real,imag-z2.imag);
 return (l);
}

complex complex::operator*(const complex &z2) const
{
 complex l(real*z2.real-imag*z2.imag,real*z2.imag+imag*z2.real);
  return (l);
}

complex complex::operator/(const complex &z2) const
{
 double delta=z2.real*z2.real+z2.imag*z2.imag;
    complex l((real*z2.real+imag*z2.imag)/delta,
        (z2.real*imag-real*z2.imag)/delta);
 return (l);
}



//void matrixbuild (); //调用子函数声明,生成导纳矩阵

////////////////////////
//结构体定义
///////////////////////
struct BranchDATA
{
	int i,j,type;
	double R,X,Yk;
};
struct NodeDATA
{
	int i;					//节点编号
	int type;				//节点类型:1为PQ节点,2为PV节点,3为平衡节点;

};

struct PVNode_Type
{
	double V;
	int i;
	
};
struct Yii_type
{
	double G,B;
};
struct Yij_type
{
	double G,B;
	int j;
};


///////////////////////
////声明全局变量
////////////////////////

extern int N ;			//node
extern int Nb ;			//支路数
extern int Ng ;			//发电机节点数
extern int Nl;			//负荷节点数]

///////////////////
////声明结构
///////////////////
extern NodeDATA * Node; 
extern BranchDATA * Branch;
extern Yii_type * Yii;
extern Yii_type * Y1ii;
extern Yij_type * Yij;
extern Yij_type * Y1ij;
extern int *NYsum;		//储存各行非对角元素的个数
extern int * NYseq;		///各行非对角元素的首地址
extern complex **c;
///////////////////////
///声明函数
///////////////////////
void readfile ( char filename[10] );
void BuildY1 ();
//void BuildY2 ();
void OutputBranch (BranchDATA *p,int Nb);
void OutputNode (NodeDATA *p,int N);
void OutputY ();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -