Commit 78cb0dc9 authored by Jan Dinkelbach's avatar Jan Dinkelbach Committed by Markus Mirz
Browse files

allow for switching off control of vsi in dp1ph

parent 347d34d1
......@@ -25,19 +25,23 @@ int main(int argc, char* argv[]) {
Examples::SGIB::ScenarioConfig scenario;
// Real finalTime = 0.003;
Real finalTime = 10;
Real timeStep = 0.001;
Real finalTime = 2;
Real timeStep = 0.0001;
String simName = "DP_Slack_PiLine_VSI_with_PF_Init";
Bool pvWithControl = true;
CommandLineArgs args(argc, argv);
if (argc > 1) {
simName = args.name;
timeStep = args.timeStep;
finalTime = args.duration;
pvWithControl = args.options_bool["control"];
}
// ----- POWERFLOW FOR INITIALIZATION -----
Real timeStepPF = finalTime;
Real finalTimePF = finalTime+timeStepPF;
String simNamePF = "DP_Slack_PiLine_VSI_with_PF_Init_PF";
String simNamePF = simName+"_PF";
Logger::setLogDir("logs/" + simNamePF);
// Components
......@@ -84,7 +88,7 @@ int main(int argc, char* argv[]) {
// ----- DYNAMIC SIMULATION -----
Real timeStepDP = timeStep;
Real finalTimeDP = finalTime+timeStepDP;
String simNameDP = "DP_Slack_PiLine_VSI_with_PF_Init_DP";
String simNameDP = simName+"_DP";
Logger::setLogDir("logs/" + simNameDP);
// Components
......@@ -104,6 +108,7 @@ int main(int argc, char* argv[]) {
pv->setFilterParameters(scenario.Lf, scenario.Cf, scenario.Rf, scenario.Rc);
pv->setTransformerParameters(scenario.systemNominalVoltage, scenario.pvNominalVoltage, scenario.transformerNominalPower, scenario.systemNominalVoltage/scenario.pvNominalVoltage, 0, 0, scenario.transformerInductance, scenario.systemOmega);
pv->setInitialStateValues(scenario.pvNominalActivePower, scenario.pvNominalReactivePower, scenario.phi_dInit, scenario.phi_qInit, scenario.gamma_dInit, scenario.gamma_qInit);
pv->withControl(pvWithControl);
// Topology
extnetDP->connect({ n1DP });
......
......@@ -162,10 +162,161 @@
plt.plot(ts_obj.time, ts_obj.values, label=ts_name+'_control_off', linestyle=':')
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
## DP simulations with control on and off
%% Cell type:code id: tags:
``` python
%%bash
TOP=${TOP:-$(git rev-parse --show-toplevel)}
PATH=${TOP}/build/Examples/Cxx
TIMESTEP=0.1e-3
DURATION=1
DP_Slack_PiLine_VSI_with_PF_Init --name="DP_Slack_PiLine_VSI_with_PF_ControlOn" --option="control=true" --timestep=${TIMESTEP} --duration=${DURATION}
DP_Slack_PiLine_VSI_with_PF_Init --name="DP_Slack_PiLine_VSI_with_PF_ControlOff" --option="control=false" --timestep=${TIMESTEP} --duration=${DURATION}
```
%% Cell type:markdown id: tags:
## PF results
%% Cell type:code id: tags:
``` python
modelName = 'DP_Slack_PiLine_VSI_with_PF_ControlOn_PF'
path = 'logs/' + modelName + '/'
dpsim_result_file = path + modelName + '.csv'
ts_dpsim_pf = read_timeseries_csv(dpsim_result_file)
```
%% Cell type:markdown id: tags:
## DP results with control on
%% Cell type:code id: tags:
``` python
modelName = 'DP_Slack_PiLine_VSI_with_PF_ControlOn_DP'
path = 'logs/' + modelName + '/'
dpsim_result_file = path + modelName + '.csv'
ts_dpsim = read_timeseries_csv(dpsim_result_file)
```
%% Cell type:markdown id: tags:
## DP results with control off
%% Cell type:code id: tags:
``` python
modelName = 'DP_Slack_PiLine_VSI_with_PF_ControlOff_DP'
path = 'logs/' + modelName + '/'
dpsim_result_file = path + modelName + '.csv'
ts_dpsim_no_control = read_timeseries_csv(dpsim_result_file)
```
%% Cell type:markdown id: tags:
## DP plot of grid quantities
%% Cell type:markdown id: tags:
### Voltages
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
ts_of_interest = ['v1', 'v2']
for ts_name, ts_obj in ts_dpsim_pf.items():
if ts_name in ts_of_interest:
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name+'_pf')
for ts_name, ts_obj in ts_dpsim.items():
if ts_name in ts_of_interest:
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name+'_control_on')
for ts_name, ts_obj in ts_dpsim_no_control.items():
if ts_name in ts_of_interest:
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name+'_control_off', linestyle=':')
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
### Currents
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
ts_of_interest = ['i12'] # 'i12_1','i12_2'
for ts_name, ts_obj in ts_dpsim.items():
if ts_name in ts_of_interest:
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name+'_control_on')
for ts_name, ts_obj in ts_dpsim_no_control.items():
if ts_name in ts_of_interest:
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name+'_control_off', linestyle=':')
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
## DP plot of VSI variables
%% Cell type:markdown id: tags:
### States - Power
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
ts_of_interest = ['pv_powerctrl_input_pref', 'pv_powerctrl_input_qref']
for ts_name, ts_obj in ts_dpsim.items():
if ts_name in ts_of_interest:
plt.plot(ts_obj.time, ts_obj.values, label=ts_name)
ts_of_interest = ['pv_powerctrl_state_p', 'pv_powerctrl_state_q']
for ts_name, ts_obj in ts_dpsim.items():
if ts_name in ts_of_interest:
plt.plot(ts_obj.time, ts_obj.values, label=ts_name+'_control_on')
for ts_name, ts_obj in ts_dpsim_no_control.items():
if ts_name in ts_of_interest:
plt.plot(ts_obj.time, ts_obj.values, label=ts_name+'_control_off', linestyle=':')
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
### Outputs - Voltage
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
ts_of_interest = ['pv_vs']
for ts_name, ts_obj in ts_dpsim.items():
if ts_name in ts_of_interest:
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name+'_control_on')
for ts_name, ts_obj in ts_dpsim_no_control.items():
if ts_name in ts_of_interest:
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name+'_control_off', linestyle=':')
plt.legend()
plt.show()
```
%% Cell type:code id: tags:
``` python
```
......
......@@ -78,8 +78,10 @@ namespace Ph1 {
/// Voltage as control output after transformation interface
MatrixComp mVsref = MatrixComp::Zero(1,1);
/// Boolean for connection transformer usage
/// Flag for connection transformer usage
Bool mWithConnectionTransformer=false;
/// Flag for controller usage
Bool mWithControl=true;
// #### solver ####
///
......@@ -107,6 +109,7 @@ namespace Ph1 {
/// Setter for initial values applied in controllers
void setInitialStateValues(Real pInit, Real qInit,
Real phi_dInit, Real phi_qInit, Real gamma_dInit, Real gamma_qInit);
void withControl(Bool controlOn) { mWithControl = controlOn; };
// #### MNA section ####
/// Initializes internal variables of the component
......
......@@ -59,6 +59,9 @@ DP::Ph1::AvVoltageSourceInverterDQ::AvVoltageSourceInverterDQ(String uid, String
addAttribute<Real>("Irc_q", &mIrcq, Flags::read | Flags::write);
addAttribute<MatrixComp>("Vsref", &mVsref, Flags::read | Flags::write);
// Sub voltage source
addAttributeRef<MatrixComp>("Vs", mSubCtrledVoltageSource->attribute<MatrixComp>("v_intf"), Flags::read | Flags::write);
// PLL
mPLL->setAttributeRef("input_ref", attribute<Real>("Vc_q"));
addAttributeRef<Matrix>("pll_output", mPLL->attribute<Matrix>("output_curr"), Flags::read);
......@@ -334,7 +337,8 @@ void DP::Ph1::AvVoltageSourceInverterDQ::mnaAddPreStepDependencies(AttributeBase
void DP::Ph1::AvVoltageSourceInverterDQ::mnaPreStep(Real time, Int timeStepCount) {
// pre-steo of subcomponents - controlled source
mSubCtrledVoltageSource->setParameters(mVsref(0,0));
if (mWithControl)
mSubCtrledVoltageSource->setParameters(mVsref(0,0));
// pre-step of subcomponents - others
for (auto subcomp: mSubComponents)
if (auto mnasubcomp = std::dynamic_pointer_cast<MNAInterface>(subcomp))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment