Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lecture-tutorials
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACS
Public
Teaching materials
Systemtheorie 2
lecture-tutorials
Commits
5dcce606
Commit
5dcce606
authored
3 years ago
by
Charukeshi Mayuresh Joglekar
Browse files
Options
Downloads
Patches
Plain Diff
Upload notebook for V9
parent
1046c155
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ACS Notebooks/ACS_V9.ipynb
+339
-0
339 additions, 0 deletions
ACS Notebooks/ACS_V9.ipynb
with
339 additions
and
0 deletions
ACS Notebooks/ACS_V9.ipynb
0 → 100644
+
339
−
0
View file @
5dcce606
{
"cells": [
{
"cell_type": "markdown",
"id": "6abc5329-fdea-4f76-ad5f-f6e8ecc8cdac",
"metadata": {},
"source": [
"Design and Simulation of a Grid Forming Inverter\n",
"System definition\n",
"This notebook presents the complete design and verification of an inverter working as grid forming"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bc402d67",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"clear all\n",
"% Set the Octave Engine to run the simulation\n",
"SetSimulationEnvironment;\n",
"% Input Data\n",
"Rf = 0.1\n",
"Lf = 0.01\n",
"Rc = 0.01\n",
"Cf = 0.001\n",
"Rl = 10\n",
"Ll = 0.1\n",
"om = 2*pi*50\n",
"Vref = sqrt(3)*220"
]
},
{
"cell_type": "markdown",
"id": "446033c6",
"metadata": {},
"source": [
"Current Loop\n",
"First thing we design the current loop compensating the pole of the inductance and fixing the\n",
"bandwidth"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "02055711",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"ombc = 600*2*pi\n",
"Kpc = ombc*Lf\n",
"Kic = ombc*Rf"
]
},
{
"cell_type": "markdown",
"id": "d3944599",
"metadata": {},
"source": [
"As result we have the following frequency responses\n",
"Open loop current"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6a86cc64",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"Gc = tf(1,[Lf Rf])\n",
"bode(Gc)"
]
},
{
"cell_type": "markdown",
"id": "556532ab",
"metadata": {},
"source": [
"Adding the controller to the open loop"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bd6ffa04",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"Rcur = tf([Kpc Kic],[1 0])\n",
"Gopenc = Rcur*Gc\n",
"bode(Gopenc)"
]
},
{
"cell_type": "markdown",
"id": "9415b65d",
"metadata": {},
"source": [
"Voltage Loop\n",
"The design is performed by tuning the PI control and assuming that ESR does not play a role and\n",
"that the current loop is too fast for the voltage loop"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ac110f53",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"ombv = 100*2*pi\n",
"fim = 60*pi/180\n",
"Gv = tf(1,[Cf 0])\n",
"[Go Fo]= bode(Gv,ombv)\n",
"Fo = Fo*pi/180;\n",
"Kpv = cos(-pi+fim-Fo)/Go\n",
"Kiv = -sin(-pi+fim-Fo)*ombv/Go"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4dead95b",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"Rv = tf([Kpv Kiv],[1 0])\n",
"Gopenv = Rv*Gv\n",
"margin(Gopenv)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9d1a0433",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"% Set the Octave Engine to run the simulation\n",
"SetSimulationEnvironment;\n",
"tini = 0;\n",
"tfinal = 0.1;\n",
"dt = 0.0001;\n",
"nflows = 44;\n",
"nnode = 23;\n",
"maxn = 20;\n",
"toll = 0.0001;\n",
"% Creating an hybrid diagram containing a power network and control\n",
"hy = HybridSystem(nnode,nflows,tini,tfinal,dt,maxn,toll);\n",
"% POWER NETWORK TOPOLOGY - Inverter+Filter+Load\n",
"% Voltage Source\n",
"c1{1} = Signal2Source(1,0,24);\n",
"c1{2} = Signal2Source(2,0,25);\n",
"c1{3} = Signal2Source(3,0,26);\n",
"% Resistor\n",
"c1{4} = Resistance(1,4,Rf);\n",
"c1{5} = Resistance(2,5,Rf);\n",
"c1{6} = Resistance(3,6,Rf);\n",
"% Inductor\n",
"c1{7} = Inductor(4,7,Lf);\n",
"c1{8} = Inductor(5,8,Lf);\n",
"c1{9} = Inductor(6,9,Lf);\n",
"% Current Sensors\n",
"c1{10} = CurrentSensor(7,10,29);\n",
"c1{11} = CurrentSensor(8,11,30);\n",
"c1{12} = CurrentSensor(9,12,31);\n",
"% Capacitor Resistances\n",
"c1{13} = Resistance(10,20,Rc);\n",
"c1{14} = Resistance(11,21,Rc);\n",
"c1{15} = Resistance(12,22,Rc);\n",
"% Capacitor Filter\n",
"c1{16} = Capacitor(20,23,Cf);\n",
"c1{17} = Capacitor(21,23,Cf);\n",
"c1{18} = Capacitor(22,23,Cf);\n",
"% Line/Load Resistance\n",
"c1{19} = Resistance(10,13,Rl);\n",
"c1{20} = Resistance(11,14,Rl);\n",
"c1{21} = Resistance(12,15,Rl);\n",
"% Line/Load Inductor\n",
"c1{22} = Inductor(13,16,Ll);\n",
"c1{23} = Inductor(14,17,Ll);\n",
"c1{24} = Inductor(15,18,Ll);\n",
"% Current sensors on line\n",
"c1{25} = CurrentSensor(16,19,34);\n",
"c1{26} = CurrentSensor(17,19,35);\n",
"c1{27} = CurrentSensor(18,19,36);\n",
"% Voltage sensors across capacitors\n",
"c1{28} = VoltageSensor(10,23,39);\n",
"c1{29} = VoltageSensor(11,23,40);\n",
"c1{30} = VoltageSensor(12,23,41);\n",
"% Adding all the components to the network diagram\n",
"hy.AddListComponents2Network(c1);\n",
"CONTROL SYSTEM\n",
"% Voltage Control\n",
"b1{1} = Constant(1,Vref);\n",
"b1{2} = Constant(2,0);\n",
"b1{3} = Sum(1,42,3,1,-1);\n",
"b1{4} = Sum(2,43,4,1,-1);\n",
"b1{5} = PI(3,5,Kpv,Kiv,0);\n",
"b1{6} = PI(4,6,Kpv,Kiv,0);\n",
"% Feedforward and decoupling voltage loop\n",
"b1{7} = Sum(5,8,9,1,1);\n",
"b1{8} = Sum(6,7,10,1,-1);\n",
"b1{9} = Gain(43,8,2*pi*50*Cf);\n",
"b1{10} = Gain(42,7,2*pi*50*Cf);\n",
"b1{11} = Sum(9,37,11,1,1);\n",
"b1{12} = Sum(10,38,12,1,1);\n",
"% Current Control\n",
"b1{13} = Sum(11,32,13,1,-1);\n",
"b1{14} = Sum(12,33,14,1,-1);\n",
"b1{15} = PI(13,15,Kpc,Kic,0);\n",
"b1{16} = PI(14,17,Kpc,Kic,0);\n",
"% Feedforward and decoupling current loop\n",
"b1{17} = Sum(15,16,19,1,1);\n",
"b1{18} = Sum(17,18,20,1,-1);\n",
"b1{19} = Gain(33,16,2*pi*50*Lf);\n",
"b1{20} = Gain(32,18,2*pi*50*Lf);\n",
"b1{21} = Sum(19,42,21,1,1);\n",
"b1{22} = Sum(20,43,22,1,1);\n",
"% Park Output Voltage Reference\n",
"b1{23} = InvPark(21,22,2,24,25,26,23);\n",
"% Angle Reference\n",
"b1{24} = Constant(27,2*pi*50);\n",
"b1{25} = Integrator(27,23,0);\n",
"% Measurement Current Filter\n",
"b1{26} = Park(29,30,31,32,33,44,23);\n",
"% Measurement Voltage Filter\n",
"b1{27} = Park(39,40,41,42,43,44,23);\n",
"% Measurement Current Load\n",
"b1{28} = Park(34,35,36,37,38,44,23);\n",
"% Adding all the components to the Control Schema\n",
"hy.AddListComponents2Schema(b1);\n",
"% Initialization\n",
"hy.Init();\n",
"p=1;\n",
"% Simulation Loop\n",
"while hy.Step()\n",
"time(p) = hy.GetTime();\n",
"% Park Voltage\n",
"out(1,p) = hy.GetFlow(42);\n",
"out(2,p) = hy.GetFlow(43);\n",
"% Park Currents\n",
"out(3,p) = hy.GetFlow(32);\n",
"out(4,p) = hy.GetFlow(33);\n",
"% Phase Voltages\n",
"out(5,p) = hy.GetFlow(39);\n",
"out(6,p) = hy.GetFlow(40);\n",
"out(7,p) = hy.GetFlow(41);\n",
"% Phase Currents\n",
"out(8,p) = hy.GetFlow(34);\n",
"out(9,p) = hy.GetFlow(35);\n",
"out(10,p) = hy.GetFlow(36);\n",
"p=p+1;\n",
"end"
]
},
{
"cell_type": "markdown",
"id": "d03968d1",
"metadata": {},
"source": [
"Park Voltages on the filter"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "754899a0",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"plot(time,out(1,:),time,out(2,:));"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Octave",
"language": "octave",
"name": "octave"
},
"language_info": {
"file_extension": ".m",
"help_links": [
{
"text": "GNU Octave",
"url": "https://www.gnu.org/software/octave/support.html"
},
{
"text": "Octave Kernel",
"url": "https://github.com/Calysto/octave_kernel"
},
{
"text": "MetaKernel Magics",
"url": "https://metakernel.readthedocs.io/en/latest/source/README.html"
}
],
"mimetype": "text/x-octave",
"name": "octave",
"version": "5.2.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:markdown id:6abc5329-fdea-4f76-ad5f-f6e8ecc8cdac tags:
Design and Simulation of a Grid Forming Inverter
System definition
This notebook presents the complete design and verification of an inverter working as grid forming
%% Cell type:code id:bc402d67 tags:
```
octave
clear all
% Set the Octave Engine to run the simulation
SetSimulationEnvironment;
% Input Data
Rf = 0.1
Lf = 0.01
Rc = 0.01
Cf = 0.001
Rl = 10
Ll = 0.1
om = 2*pi*50
Vref = sqrt(3)*220
```
%% Cell type:markdown id:446033c6 tags:
Current Loop
First thing we design the current loop compensating the pole of the inductance and fixing the
bandwidth
%% Cell type:code id:02055711 tags:
```
octave
ombc = 600*2*pi
Kpc = ombc*Lf
Kic = ombc*Rf
```
%% Cell type:markdown id:d3944599 tags:
As result we have the following frequency responses
Open loop current
%% Cell type:code id:6a86cc64 tags:
```
octave
Gc = tf(1,[Lf Rf])
bode(Gc)
```
%% Cell type:markdown id:556532ab tags:
Adding the controller to the open loop
%% Cell type:code id:bd6ffa04 tags:
```
octave
Rcur = tf([Kpc Kic],[1 0])
Gopenc = Rcur*Gc
bode(Gopenc)
```
%% Cell type:markdown id:9415b65d tags:
Voltage Loop
The design is performed by tuning the PI control and assuming that ESR does not play a role and
that the current loop is too fast for the voltage loop
%% Cell type:code id:ac110f53 tags:
```
octave
ombv = 100*2*pi
fim = 60*pi/180
Gv = tf(1,[Cf 0])
[Go Fo]= bode(Gv,ombv)
Fo = Fo*pi/180;
Kpv = cos(-pi+fim-Fo)/Go
Kiv = -sin(-pi+fim-Fo)*ombv/Go
```
%% Cell type:code id:4dead95b tags:
```
octave
Rv = tf([Kpv Kiv],[1 0])
Gopenv = Rv*Gv
margin(Gopenv)
```
%% Cell type:code id:9d1a0433 tags:
```
octave
% Set the Octave Engine to run the simulation
SetSimulationEnvironment;
tini = 0;
tfinal = 0.1;
dt = 0.0001;
nflows = 44;
nnode = 23;
maxn = 20;
toll = 0.0001;
% Creating an hybrid diagram containing a power network and control
hy = HybridSystem(nnode,nflows,tini,tfinal,dt,maxn,toll);
% POWER NETWORK TOPOLOGY - Inverter+Filter+Load
% Voltage Source
c1{1} = Signal2Source(1,0,24);
c1{2} = Signal2Source(2,0,25);
c1{3} = Signal2Source(3,0,26);
% Resistor
c1{4} = Resistance(1,4,Rf);
c1{5} = Resistance(2,5,Rf);
c1{6} = Resistance(3,6,Rf);
% Inductor
c1{7} = Inductor(4,7,Lf);
c1{8} = Inductor(5,8,Lf);
c1{9} = Inductor(6,9,Lf);
% Current Sensors
c1{10} = CurrentSensor(7,10,29);
c1{11} = CurrentSensor(8,11,30);
c1{12} = CurrentSensor(9,12,31);
% Capacitor Resistances
c1{13} = Resistance(10,20,Rc);
c1{14} = Resistance(11,21,Rc);
c1{15} = Resistance(12,22,Rc);
% Capacitor Filter
c1{16} = Capacitor(20,23,Cf);
c1{17} = Capacitor(21,23,Cf);
c1{18} = Capacitor(22,23,Cf);
% Line/Load Resistance
c1{19} = Resistance(10,13,Rl);
c1{20} = Resistance(11,14,Rl);
c1{21} = Resistance(12,15,Rl);
% Line/Load Inductor
c1{22} = Inductor(13,16,Ll);
c1{23} = Inductor(14,17,Ll);
c1{24} = Inductor(15,18,Ll);
% Current sensors on line
c1{25} = CurrentSensor(16,19,34);
c1{26} = CurrentSensor(17,19,35);
c1{27} = CurrentSensor(18,19,36);
% Voltage sensors across capacitors
c1{28} = VoltageSensor(10,23,39);
c1{29} = VoltageSensor(11,23,40);
c1{30} = VoltageSensor(12,23,41);
% Adding all the components to the network diagram
hy.AddListComponents2Network(c1);
CONTROL SYSTEM
% Voltage Control
b1{1} = Constant(1,Vref);
b1{2} = Constant(2,0);
b1{3} = Sum(1,42,3,1,-1);
b1{4} = Sum(2,43,4,1,-1);
b1{5} = PI(3,5,Kpv,Kiv,0);
b1{6} = PI(4,6,Kpv,Kiv,0);
% Feedforward and decoupling voltage loop
b1{7} = Sum(5,8,9,1,1);
b1{8} = Sum(6,7,10,1,-1);
b1{9} = Gain(43,8,2*pi*50*Cf);
b1{10} = Gain(42,7,2*pi*50*Cf);
b1{11} = Sum(9,37,11,1,1);
b1{12} = Sum(10,38,12,1,1);
% Current Control
b1{13} = Sum(11,32,13,1,-1);
b1{14} = Sum(12,33,14,1,-1);
b1{15} = PI(13,15,Kpc,Kic,0);
b1{16} = PI(14,17,Kpc,Kic,0);
% Feedforward and decoupling current loop
b1{17} = Sum(15,16,19,1,1);
b1{18} = Sum(17,18,20,1,-1);
b1{19} = Gain(33,16,2*pi*50*Lf);
b1{20} = Gain(32,18,2*pi*50*Lf);
b1{21} = Sum(19,42,21,1,1);
b1{22} = Sum(20,43,22,1,1);
% Park Output Voltage Reference
b1{23} = InvPark(21,22,2,24,25,26,23);
% Angle Reference
b1{24} = Constant(27,2*pi*50);
b1{25} = Integrator(27,23,0);
% Measurement Current Filter
b1{26} = Park(29,30,31,32,33,44,23);
% Measurement Voltage Filter
b1{27} = Park(39,40,41,42,43,44,23);
% Measurement Current Load
b1{28} = Park(34,35,36,37,38,44,23);
% Adding all the components to the Control Schema
hy.AddListComponents2Schema(b1);
% Initialization
hy.Init();
p=1;
% Simulation Loop
while hy.Step()
time(p) = hy.GetTime();
% Park Voltage
out(1,p) = hy.GetFlow(42);
out(2,p) = hy.GetFlow(43);
% Park Currents
out(3,p) = hy.GetFlow(32);
out(4,p) = hy.GetFlow(33);
% Phase Voltages
out(5,p) = hy.GetFlow(39);
out(6,p) = hy.GetFlow(40);
out(7,p) = hy.GetFlow(41);
% Phase Currents
out(8,p) = hy.GetFlow(34);
out(9,p) = hy.GetFlow(35);
out(10,p) = hy.GetFlow(36);
p=p+1;
end
```
%% Cell type:markdown id:d03968d1 tags:
Park Voltages on the filter
%% Cell type:code id:754899a0 tags:
```
octave
plot(time,out(1,:),time,out(2,:));
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment