Skip to content

Commit

Permalink
add vsg_model and vsgcontrol model. not tested. need to rename VSG0 a…
Browse files Browse the repository at this point in the history
…nd VSG1 model for VSCHVDC
changgang committed Jan 24, 2024
1 parent 11b5623 commit 5bb86a3
Showing 8 changed files with 798 additions and 11 deletions.
4 changes: 4 additions & 0 deletions code/steps/STEPS.cbp
Original file line number Diff line number Diff line change
@@ -343,6 +343,8 @@
<Unit filename="header/model/vsc_hvdc_model/vsc_hvdc_network_model/VSCHVDCP0.h" />
<Unit filename="header/model/vsc_hvdc_model/vsc_hvdc_network_model/vsc_hvdc_network_model.h" />
<Unit filename="header/model/vsc_hvdc_model/vsc_hvdc_network_model/vsc_hvdc_network_models.h" />
<Unit filename="header/model/vsg_model/vsg_model.h" />
<Unit filename="header/model/vsg_model/vsgcontrol0.h" />
<Unit filename="header/model/wtg_models/wind_speed_model/filewind.h" />
<Unit filename="header/model/wtg_models/wind_speed_model/filewind_test.h" />
<Unit filename="header/model/wtg_models/wind_speed_model/wind_speed_model.h" />
@@ -749,6 +751,8 @@
<Unit filename="source/model/vsc_hvdc_model/vsc_hvdc_model_test.cpp" />
<Unit filename="source/model/vsc_hvdc_model/vsc_hvdc_network_model/VSCHVDCP0.cpp" />
<Unit filename="source/model/vsc_hvdc_model/vsc_hvdc_network_model/vsc_hvdc_network_model.cpp" />
<Unit filename="source/model/vsg_model/vsg_model.cpp" />
<Unit filename="source/model/vsg_model/vsgcontrol0.cpp" />
<Unit filename="source/model/wtg_models/wind_speed_model/filewind.cpp" />
<Unit filename="source/model/wtg_models/wind_speed_model/filewind_test.cpp" />
<Unit filename="source/model/wtg_models/wind_speed_model/wind_speed_model.cpp" />
39 changes: 36 additions & 3 deletions code/steps/STEPS.depend
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@
<functional>
"terminal.h"

1664187911 d:\steps\code\steps\header\basic\constants.h
1706061373 d:\steps\code\steps\header\basic\constants.h

1664187911 d:\steps\code\steps\header\basic\terminal.h
<vector>
@@ -4256,7 +4256,7 @@
<cstdio>
<cmath>

1700647330 source:d:\steps\code\steps\source\model\model.cpp
1706064347 source:d:\steps\code\steps\source\model\model.cpp
"header/model/model.h"
<cstdio>
"header/basic/utility.h"
@@ -5224,7 +5224,7 @@
"header/basic/constants.h"
<cmath>

1706019282 source:d:\steps\code\steps\source\model\wtg_models\wt_generator_model\wt3g0.cpp
1706065923 source:d:\steps\code\steps\source\model\wtg_models\wt_generator_model\wt3g0.cpp
"header/model/wtg_models/wt_generator_model/wt3g0.h"
"header/basic/utility.h"
"header/steps_namespace.h"
@@ -56587,3 +56587,36 @@
<istream>
<iostream>

1706070726 source:d:\steps\code\steps\source\model\vsg_model\vsg0.cpp
"header/model/vsg_model/vsg0.h"
"header/basic/utility.h"
"header/power_system_database.h"
"header/STEPS.h"

1706070726 d:\steps\code\steps\header\model\vsg_model\vsg0.h
"header/model/vsg_model/vsg_model.h"
"header/block/integral_block.h"
<complex>

1706070254 d:\steps\code\steps\header\model\vsg_model\vsg_model.h
"header/model/model.h"
"header/device/bus.h"
<complex>

1706070274 source:d:\steps\code\steps\source\model\vsg_model\vsg_model.cpp
"header/model/vsg_model/vsg_model.h"
"header/basic/utility.h"
"header/power_system_database.h"
"header/STEPS.h"

1706071014 source:d:\steps\code\steps\source\model\vsg_model\vsgcontrol0.cpp
"header/model/vsg_model/vsgcontrol0.h"
"header/basic/utility.h"
"header/power_system_database.h"
"header/STEPS.h"

1706071022 d:\steps\code\steps\header\model\vsg_model\vsgcontrol0.h
"header/model/vsg_model/vsg_model.h"
"header/block/integral_block.h"
<complex>

2 changes: 1 addition & 1 deletion code/steps/header/basic/constants.h
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ const unsigned int STEPS_SHORT_STRING_SIZE = 64;
const unsigned int STEPS_MEDIUM_STRING_SIZE = 128;
const unsigned int STEPS_LONG_STRING_SIZE = 256;
const unsigned int STEPS_METER_TYPE_STRING_SIZE = STEPS_SHORT_STRING_SIZE;
const unsigned int STEPS_MODEL_MAX_ALLOWED_DEVICE_COUNT = 2;
const unsigned int STEPS_MODEL_MAX_ALLOWED_DEVICE_COUNT = 5;
const unsigned int STEPS_MAX_DC_NETWORK_BUS_SIZE = 20;
const unsigned int STEPS_MAX_DC_NETWORK_LINE_SIZE = 10;

85 changes: 85 additions & 0 deletions code/steps/header/model/vsg_model/vsg_model.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#ifndef VSG_MODEL_H
#define VSG_MODEL_H

#include "header/model/model.h"
#include "header/device/bus.h"
#include <complex>

class SOURCE;
class WT_GENERATOR;
class PV_UNIT;
class ENERGY_STORAGE;

class VSG_MODEL : public MODEL
{
/*
input: device active, reactive power and terminal voltage
output: voltage magnitude and angle of internal voltage source
*/
public:
VSG_MODEL(STEPS& toolkit);
virtual ~VSG_MODEL();
virtual string get_model_type() const;

SOURCE* get_source_pointer() const;
WT_GENERATOR* get_wt_generator_pointer() const;
PV_UNIT* get_pv_unit_pointer() const;
ENERGY_STORAGE* get_enerage_storage_pointer() const;

double get_mbase_in_MVA() const;
double get_one_over_mbase_in_one_over_MVA() const;

complex<double> get_terminal_complex_power_in_pu_based_on_mbase() const;
double get_terminal_voltage_in_pu() const;
complex<double> get_terminal_complex_voltage_in_pu() const;
double get_terminal_voltage_angle_in_rad() const;
double get_bus_base_frequency_in_Hz() const;
double get_bus_base_angle_speed_in_radps() const;
complex<double> get_source_impedance_in_pu_based_on_mbase() const;

void set_Pref_in_pu_based_on_mbase(double P);
void set_Qref_in_pu_based_on_mbase(double Q);
void set_Vref_in_pu(double V);

double get_Pref_in_pu_based_on_mbase() const;
double get_Qref_in_pu_based_on_mbase() const;
double get_Vref_in_pu() const;

double get_virtual_speed_in_pu() const;
public: // specific model level
virtual double get_virtual_speed_deviation_in_pu() const = 0;
virtual double get_virtual_angle_in_rad() const = 0;
virtual double get_virtual_voltage_in_pu() const = 0;

virtual string get_model_name() const = 0;

virtual bool setup_model_with_steps_string_vector(vector<string>& data) = 0;
virtual bool setup_model_with_psse_string(string data) = 0;
virtual bool setup_model_with_bpa_string(string data) = 0;

virtual void setup_block_toolkit_and_parameters() = 0;

virtual void initialize() = 0;
virtual void run(DYNAMIC_MODE mode) = 0;

virtual void check() = 0;
virtual void clear() = 0;
virtual void report() = 0;
virtual void save() = 0;
virtual string get_standard_psse_string(bool export_internal_bus_number=false) const = 0;

virtual void prepare_model_data_table() = 0;
virtual double get_model_data_with_name(string par_name) const = 0;
virtual void set_model_data_with_name(string par_name, double value) = 0;
virtual double get_minimum_nonzero_time_constant_in_s() = 0;

virtual void prepare_model_internal_variable_table() = 0;
virtual double get_model_internal_variable_with_name(string var_name)= 0;

virtual string get_dynamic_data_in_psse_format() const = 0;
virtual string get_dynamic_data_in_bpa_format() const = 0;
virtual string get_dynamic_data_in_steps_format() const = 0;
private:
double Pref, Qref, Vref;
};
#endif // VSG_MODEL_H
66 changes: 66 additions & 0 deletions code/steps/header/model/vsg_model/vsgcontrol0.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#ifndef VSG0_H
#define VSG0_H

#include "header/model/vsg_model/vsg_model.h"
#include "header/block/integral_block.h"
#include <complex>

class VSGCONTROL0 : public VSG_MODEL
{
public:
VSGCONTROL0(STEPS& toolkit);
VSGCONTROL0(const VSGCONTROL0& model);
virtual ~VSGCONTROL0();
virtual VSGCONTROL0& operator=(const VSGCONTROL0& model);

void set_Tj_in_s(double Tj);
void set_D(double D);
void set_Ku(double Ku);
void set_Te_in_s(double Ke);

double get_Tj_in_s() const;
double get_D() const;
double get_Ku() const;
double get_Te_in_s() const;

public: // specific model level
virtual string get_model_name() const;

virtual bool setup_model_with_steps_string_vector(vector<string>& data);
virtual bool setup_model_with_psse_string(string data);
virtual bool setup_model_with_bpa_string(string data);

virtual void setup_block_toolkit_and_parameters();

virtual void initialize();
virtual void run(DYNAMIC_MODE mode);

virtual void check();
virtual void clear();
virtual void report();
virtual void save();
virtual string get_standard_psse_string(bool export_internal_bus_number=false) const;

virtual void prepare_model_data_table();
virtual double get_model_data_with_name(string par_name) const;
virtual void set_model_data_with_name(string par_name, double value);
virtual double get_minimum_nonzero_time_constant_in_s();

virtual void prepare_model_internal_variable_table();
virtual double get_model_internal_variable_with_name(string var_name);

virtual string get_dynamic_data_in_psse_format() const;
virtual string get_dynamic_data_in_bpa_format() const;
virtual string get_dynamic_data_in_steps_format() const;

virtual double get_virtual_speed_deviation_in_pu() const;
virtual double get_virtual_angle_in_rad() const;
virtual double get_virtual_voltage_in_pu() const;
private:
void copy_from_const_model(const VSGCONTROL0& model);
private:
double D, Ku;
INTEGRAL_BLOCK virtual_speed_deviation_block, virtual_angle_block, virtual_voltage_block;

};
#endif // VSG0_H
8 changes: 1 addition & 7 deletions code/steps/source/model/model.cpp
Original file line number Diff line number Diff line change
@@ -304,16 +304,10 @@ void MODEL::set_device_id(DEVICE_ID did)
switch(device_type)
{
case STEPS_GENERATOR:
bus_pointer = ((GENERATOR*) device_pointer)->get_bus_pointer();
return;
case STEPS_WT_GENERATOR:
bus_pointer = ((WT_GENERATOR*) device_pointer)->get_bus_pointer();
return;
case STEPS_PV_UNIT:
bus_pointer = ((PV_UNIT*) device_pointer)->get_bus_pointer();
return;
case STEPS_ENERGY_STORAGE:
bus_pointer = ((ENERGY_STORAGE*) device_pointer)->get_bus_pointer();
bus_pointer = ((SOURCE*) device_pointer)->get_bus_pointer();
return;
case STEPS_LOAD:
bus_pointer = ((LOAD*) device_pointer)->get_bus_pointer();
Loading

0 comments on commit 5bb86a3

Please sign in to comment.