Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
sparrowzz
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
sgool
sparrowzz
Commits
172a4d27
Commit
172a4d27
authored
Jul 22, 2025
by
dongshufeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: change sparse funciton logic, add full function to use dense matrix
parent
f34c0dac
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
15 行增加
和
15 行删除
+15
-15
rspower/lib/bustypes.txt
+3
-3
rspower/lib/ext2int.txt
+1
-1
rspower/lib/make_sbus.txt
+1
-1
rspower/lib/make_y_bus.txt
+9
-9
rspower/lib/runpf.txt
+1
-1
没有找到文件。
rspower/lib/bustypes.txt
查看文件 @
172a4d27
...
...
@@ -19,7 +19,7 @@ fn bustypes_ref(bus, gen) {
nb = size(bus, 0);
ng = size(gen, 0);
g_i = slice(gen, [0], [GEN_BUS-1,GEN_BUS]) - 1; // generator bus indices
Cg =
sparse(g_i, range(0, ng), slice(gen, [0], [GEN_STATUS-1,GEN_STATUS]) > 0, nb, ng
); // gen connection matrix
Cg =
full(sparse(g_i, range(0, ng), slice(gen, [0], [GEN_STATUS-1,GEN_STATUS]) > 0, nb, ng)
); // gen connection matrix
// element i, j is 1 if, generator j at bus i is ON
bus_gen_status = Cg * ones(ng, 1); // number of generators at each bus that are ON
...
...
@@ -37,7 +37,7 @@ fn bustypes_pv(bus, gen) {
nb = size(bus, 0);
ng = size(gen, 0);
g_i = slice(gen, [0], [GEN_BUS-1,GEN_BUS]) - 1; // generator bus indices
Cg = sparse(g_i, range(0, ng), slice(gen, [0], [GEN_STATUS-1,GEN_STATUS]) > 0, nb, ng); // gen connection matrix
Cg =
full(
sparse(g_i, range(0, ng), slice(gen, [0], [GEN_STATUS-1,GEN_STATUS]) > 0, nb, ng); // gen connection matrix
// element i, j is 1 if, generator j at bus i is ON
bus_gen_status = Cg * ones(ng, 1); // number of generators at each bus that are ON
...
...
@@ -55,7 +55,7 @@ fn bustypes_pq(bus, gen) {
nb = size(bus, 0);
ng = size(gen, 0);
g_i = slice(gen, [0], [GEN_BUS-1,GEN_BUS]) - 1; // generator bus indices
Cg = sparse(g_i, range(0, ng), slice(gen, [0], [GEN_STATUS-1,GEN_STATUS]) > 0, nb, ng); // gen connection matrix
Cg =
full(
sparse(g_i, range(0, ng), slice(gen, [0], [GEN_STATUS-1,GEN_STATUS]) > 0, nb, ng); // gen connection matrix
// element i, j is 1 if, generator j at bus i is ON
bus_gen_status = Cg * ones(ng, 1); // number of generators at each bus that are ON
...
...
rspower/lib/ext2int.txt
查看文件 @
172a4d27
...
...
@@ -16,7 +16,7 @@ fn ext2int(bus, gen, branch, areas){
// create map of external bus numbers to bus indices
i2e = slice(bus, [0], [BUS_I-1,BUS_I] ); //得到bus矩阵的母线序号所在列
e2i =
sparse(range(0,max(i2e))', zeros(max(i2e),1), zeros(max(i2e),1), max(i2e), 1
); //创建(原bus矩阵母线最大序号值*1)的e2i全零稀疏矩阵
e2i =
full(sparse(range(0,max(i2e))', zeros(max(i2e),1), zeros(max(i2e),1), max(i2e), 1)
); //创建(原bus矩阵母线最大序号值*1)的e2i全零稀疏矩阵
index_e2i = i2e - 1; //索引值=母线序号-1
e2i = set(e2i, index_e2i, range(1, size(bus, 0) + 1 )' ); //建立母线序号的映射,对应位置进行从1重新编号
...
...
rspower/lib/make_sbus.txt
查看文件 @
172a4d27
...
...
@@ -34,7 +34,7 @@ fn make_sbus(baseMVA, bus, gen) {
on = find(slice(gen, [0], [GEN_STATUS-1, GEN_STATUS]) > 0); // which generators are on?
gbus = get_multi(slice(gen, [0], [GEN_BUS-1, GEN_BUS]), on) - 1; // what buses are they at?
ngon = size(on, 0);
Cg =
sparse(gbus, range(0, ngon), 1, nb, ngon
);
Cg =
full(sparse(gbus, range(0, ngon), 1, nb, ngon)
);
Gp = slice(gen, [0], [PG-1, PG]);
Gq = slice(gen, [0], [PG-1, PG]);
Sbusg = Cg * (get_multi(Gp, on) + c(0,1) * get_multi(Gq, on)) / baseMVA;
...
...
rspower/lib/make_y_bus.txt
查看文件 @
172a4d27
...
...
@@ -41,31 +41,31 @@ fn make_y_bus(baseMVA, bus, branch) {
// at each branch's "from" bus, and Yt is the same for the "to" bus end
i = horzcat(range(0, nl),range(0, nl)) - 1; // double set of row indices
j = range(0,nb);
Yf =
sparse(i, horzcat(f, t), upper, nl, nb
);
Yt =
sparse(i, horzcat(f, t), lower, nl, nb
);
Yf =
full(sparse(i, horzcat(f, t), upper, nl, nb)
);
Yt =
full(sparse(i, horzcat(f, t), lower, nl, nb)
);
// build Ybus
// branch admittances + shunt admittance
Ybus =
sparse(horzcat(f,f,t,t), horzcat(f,t,f,t), vertcat(Yff,Yft,Ytf,Ytt), nb, nb
) +
sparse(j, j, Ysh, nb, nb
);
Ybus =
full(sparse(horzcat(f,f,t,t), horzcat(f,t,f,t), vertcat(Yff,Yft,Ytf,Ytt), nb, nb)
) +
full(sparse(j, j, Ysh, nb, nb)
);
} else {
// large case running on MATLAB
// build connection matrices
i = range(0, nl);
j = range(0, nb);
Cf =
sparse(i, f, ones(nl, 1), nl, nb
); // connection matrix for line & from buses
Ct =
sparse(i, t, ones(nl, 1), nl, nb
); // connection matrix for line & to buses
Cf =
full(sparse(i, f, ones(nl, 1), nl, nb)
); // connection matrix for line & from buses
Ct =
full(sparse(i, t, ones(nl, 1), nl, nb)
); // connection matrix for line & to buses
// build Yf and Yt such that Yf * V is the vector of complex branch currents injected
// at each branch's "from" bus, and Yt is the same for the "to" bus end
Yf =
sparse(i, i, Yff, nl, nl) * Cf + sparse(i, i, Yft, nl, nl
) * Ct;
Yt =
sparse(i, i, Ytf, nl, nl) * Cf + sparse(i, i, Ytt, nl, nl
) * Ct;
Yf =
full(sparse(i, i, Yff, nl, nl)) * Cf + full(sparse(i, i, Yft, nl, nl)
) * Ct;
Yt =
full(sparse(i, i, Ytf, nl, nl)) * Cf + full(sparse(i, i, Ytt, nl, nl)
) * Ct;
// build Ybus
// branch admittances + shunt admittance
Ybus = Cf' * Yf + Ct' * Yt +
sparse(j, j, Ysh, nb, nb
);
full(sparse(j, j, Ysh, nb, nb)
);
}
return Ybus;
...
...
rspower/lib/runpf.txt
查看文件 @
172a4d27
...
...
@@ -6,7 +6,7 @@ fn runpf() {
nb = size(bus, 0);
ng = size(gen, 0);
g_i = slice(gen, [0], [GEN_BUS-1,GEN_BUS]) - 1; // generator bus indices
Cg =
sparse(g_i, range(0, ng), slice(gen, [0], [GEN_STATUS-1,GEN_STATUS]) > 0, nb, ng
); // gen connection matrix
Cg =
full(sparse(g_i, range(0, ng), slice(gen, [0], [GEN_STATUS-1,GEN_STATUS]) > 0, nb, ng)
); // gen connection matrix
// element i, j is 1 if, generator j at bus i is ON
bus_gen_status = Cg * ones(ng, 1); // number of generators at each bus that are ON
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论