Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Restoring missing commits #1256

Merged
merged 6 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions module/powerflow/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ double node::default_overvoltage_violation_threshold = 0.00;
double node::default_undervoltage_violation_threshold = 0.00;
double node::default_voltage_fluctuation_threshold = 0.03;
OBJECT* *node::DER_objectlist = NULL;
unsigned int *node::DER_buslist = NULL;
unsigned int node::DER_nodecount = 0;
unsigned int node::DER_buscount = 0;
enumeration node::DER_violation_test = DVT_ANY;

node::node(MODULE *mod) : powerflow_object(mod)
Expand Down Expand Up @@ -2847,7 +2849,7 @@ TIMESTAMP node::sync(TIMESTAMP t0)
NR_retval=t1;

// process DER voltage fluctuations
if ( DER_objectlist != NULL )
if ( DER_objectlist != NULL && NR_retval == t1 )
{
debug("starting DER voltage fluctuation checks...");

Expand All @@ -2868,9 +2870,41 @@ TIMESTAMP node::sync(TIMESTAMP t0)
}

// process every bus looking for DER to apply
for ( unsigned int der = 0 ; der < NR_bus_count ; der++ )
if ( DER_buslist == NULL )
{
// first count the busses we need to check
DER_buscount = 0;
for ( unsigned int der = 0 ; der < NR_bus_count ; der++ )
{
BUSDATA *der_bus = NR_busdata + der;
node *der_data = OBJECTDATA(der_bus->obj,node);
if ( der_bus->obj->parent != NULL && gl_object_isa(der_bus->obj->parent,"node") )
continue; // ignore child nodes because they're already included in parent node DER_value
if ( der_data->DER_value.r != 0.0 || der_data->DER_value.i != 0.0 )
{
DER_buscount++;
}
}

// then build the bus list
DER_buslist = new unsigned int[DER_buscount];
for ( unsigned int der = 0, ndx = 0 ; der < NR_bus_count ; der++ )
{
BUSDATA *der_bus = NR_busdata + der;
node *der_data = OBJECTDATA(der_bus->obj,node);
if ( der_bus->obj->parent != NULL && gl_object_isa(der_bus->obj->parent,"node") )
continue; // ignore child nodes because they're already included in parent node DER_value
if ( der_data->DER_value.r != 0.0 || der_data->DER_value.i != 0.0 )
{
DER_buslist[ndx++] = der;
}
}
}

// process every bus looking for DER to apply
for ( unsigned int ndx = 0 ; ndx < DER_buscount ; ndx++ )
{
unsigned int der = DER_buslist[ndx];
BUSDATA *der_bus = NR_busdata + der;
node *der_data = OBJECTDATA(der_bus->obj,node);
if ( der_bus->obj->parent != NULL && gl_object_isa(der_bus->obj->parent,"node") )
Expand Down
7 changes: 6 additions & 1 deletion module/powerflow/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,16 @@ class node : public powerflow_object
FUNCTIONADDR VFD_updating_function; ///< Address for VFD updating function, if it is present
OBJECT *VFD_object; ///< Object pointer for the VFD - for later function calls

public:

NRSOLVERMODE powerflow_type;

// DER globals
static unsigned int DER_nodecount; ///< count of DER nodes
static OBJECT **DER_objectlist; ///< list of DER objects to examine for voltage fluctuations violations
static unsigned int DER_buscount; ///< count of DER busses
static unsigned int *DER_buslist; ///< list of DER bus id to examine for voltage violations

public:
double frequency; ///< frequency (only valid on reference bus) */
object reference_bus; ///< reference bus from which frequency is defined */
static unsigned int n; ///< node count */
Expand Down