资源简介
使用C++编写高斯赛德尔法的潮流计算程序,将实虚部用一个复数类处理
代码片段和文件信息
#include
#include
using namespace std;
class complex
{
public:
complex(float r=0float i=0){real=r;imag=i;}
void set(float rfloat i){real=r;imag=i;}
void setimag(float i){imag=i;}
float getimag(){return imag;}
void show(){cout< float absc(){return sqrt(real*real+imag*imag);}
float rad(){return atan(imag/real);}
float ai(){return atan(imag/real)*180/3.14159;}
int jud(){if(real!=0||imag!=0)return 1;else return 0;}
complex conj(){return complex(real-imag);}
complex operator + (complex c2){return complex(real+c2.realimag+c2.imag);}
complex operator - (complex c2){return complex(real-c2.realimag-c2.imag);}
complex operator * (complex c2){return complex(real*c2.real-imag*c2.imagimag*c2.real+real*c2.imag);}
complex operator / (complex c2){return complex((real*c2.real+imag*c2.imag)/(c2.real*c2.real+c2.imag*c2.imag)(imag*c2.real-real*c2.imag)/(c2.real*c2.real+c2.imag*c2.imag));}
~complex() {}
private:
float real;
float imag;
};
main()
{
int ijkn=5pv=4maxIter=500;
static float ybr[5][5]={{0}{01.3787-0.6240-0.75740}{0-0.6241.4539-0.82990}{0-0.7547-0.82991.58460}{0}};
static float ybi[5][5]={{-33.33330031.74600}{0-6.29173.90022.64150}{03.9002-66.98083.112063.4921}{31.74602.64153.1120-35.73790}{0063.49210-66.6667}};
static float y0r[5][5]={0};
static float y0i[5][5]={{000-1.587300}{000.2500}{00.2500.253.0234}{1.511700.2500}{00-3.174600}};
float epsdd1theta;
static float u4=1.05;
complex u[5]={complex(1.050)complex(10)complex(10)complex(10)complex(u40)};
complex s[5]={complex(00)complex(-1.6-0.8)complex(-2-1)complex(-3.7-1.3)complex(50)};
complex const c0(00);
complex c1c2c3;
complex yb[5][5]y0[5][5]sl[5][5]delta_s[5][5];
for(i=0;i {
for(j=0;j {
yb[i][j].set(ybr[i][j]ybi[i][j]);
y0[i][j].set(y0r[i][j]y0i[i][j]);
}
}
eps=0.0001;
k=0;
do{
d=0;
k++;
for(i=1;i {
if(i==pv)
{
c2=c0;
for(j=0;j {
c2=yb[i][j]*u[j]+c2;
}
c3=u[i]*c2.conj();
s[i].setimag(c3.getimag());
}
c1=s[i]/u[i];
c3=c0;
for(j=0;j if(j != i)
{
c3=yb[i][j]*u[j]+c3;
}
c2=c1.conj()-c3;
c1=c2/yb[i][i];
c3=c1-u[i];
d1=c3.absc();
if(d d=d1;
if(i==pv)
{
theta=c1.rad();
u[i].set(u4*cos(theta)u4*sin(theta));
}
else
u[i]=c1;
}
} while(d > eps && k < maxIter);
cout<<‘k‘<<‘=‘< for(i=0;i {
cout<<‘u‘< cout<
if(i==pv)
{
cout<<‘S‘< s[i].show();
cout< }
}
c2=c0;
for(j=0;j {
c2=y
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6416 2013-01-08 21:15 ld class.plg
文件 3638 2013-01-08 21:15 ld class.cpp
文件 3427 2013-01-08 21:03 ld class.dsp
文件 524 2013-01-08 21:15 ld class.dsw
文件 41984 2013-01-08 21:15 ld class.ncb
文件 48640 2013-01-08 21:15 ld class.opt
----------- --------- ---------- ----- ----
104629 6
- 上一篇:RPP算法-RobustPlanarPose-C++
- 下一篇:点扩散函数PSF
相关资源
- 点扩散函数PSF
- RPP算法-RobustPlanarPose-C++
- PnP solvers C++版本,包括P3Pf,Epnp等
- 道格拉斯算法C++实现
- c++获取cpu使用率包含系统和单进程
- C++封装的一个跨平台的线程类和锁类
- C++信号量实现互斥爸爸女儿儿子苹果
- grpc c++
- 学生成绩管理系统(MFC)
- C++开源日志库Easylogging++ V9.80版本源码
- ArcGis Engine C++ 开发教程
- Visual C++游戏编程基础 PDF+源码
- 基于遗传算法的最短路径选择问题
- 计算器 VC++
- 教学设备管理系统C++课程设计
- 定义一个Date 类,数据成员有year,m
- MFC 快速导出数据至ExcelSaveToExcel组件
- C++模拟退火算法求二维函数极值
- c++医院病房管理系统
- C++对任意阶的实对称矩阵求特征值和
- 图书管理系统C++实现
- 李龙澍 C++ 程序设计课件
- 学籍信息管理系统 C++ 代码
- C++机房机位预约管理
- VC++Spin(旋转)控件用法
- SHA1加密算法的c++实现
- 导引头模型仿真
- ROBOOP --机器人正逆解C++版本开源开源
- C++实现日志库
- 基于IE浏览器的源代码
评论
共有 条评论