Skip to content

Commit

Permalink
Add pypower geodata (#194)
Browse files Browse the repository at this point in the history
Signed-off-by: David P. Chassin <dchassin@slac.stanford.edu>
  • Loading branch information
David P. Chassin authored Apr 16, 2024
1 parent 22f6be4 commit b65b3c2
Show file tree
Hide file tree
Showing 21 changed files with 786 additions and 57 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ while [ $# -gt 0 ]; do
done
mkdir -p /usr/local/opt/gridlabd || error "you do not have permission to create /usr/local/opt/gridlabd"
autoconf --version 1>/dev/null 2>&1 || error "autoconf not installed. Did you run setup.sh?"
test "$(autoconf --version 2>/dev/null | head -n 1 | grep -o '[^ ]*$')" '>' "2.71" || error "autoconf version 2.72 or later required. Did you run setup.sh?"
test "$(autoconf --version 2>/dev/null | head -n 1 | grep -o '[^ ]*$')" '>' "2.70" || error "autoconf version 2.71 or later required. Did you run setup.sh?"
git --version 1>/dev/null 2>&1 || error "you must install git to build GridLAB-D"
test -f $SRCDIR/configure.ac || error "you must build from the source directory where configure.ac is located"
test -f $HOME/.gridlabd/bin/activate || error "$HOME/.gridlabd is not found. Run setup.sh again."
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ m4_define([versionname], sbuild_m4_esyscmd_s([build-aux/version.sh --name]))
m4_define([pkginstall], sbuild_m4_esyscmd_s([build-aux/version.sh --install]))
m4_define([pkgorigin],sbuild_m4_esyscmd_s([git rev-parse --abbrev-ref HEAD]))
AC_PREREQ([2.72])
AC_PREREQ([2.71])
AC_INIT([pkgname],[pkgversion],[gridlabd@gmail.com],[pkg])
AC_CONFIG_SRCDIR([source/gridlabd.h])
AC_CONFIG_HEADERS([source/config.h])
Expand Down
14 changes: 13 additions & 1 deletion docs/GLM/Macro/If.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ GLM:

# Description

The `#if` macro introduces a conditional section of a GLM file. The `#else` and `#endif` macros are used to introduce the alternative section and terminate the conditional section.
The `#if` macro introduces a conditional section of a GLM file. The `#else`
and `#endif` macros are used to introduce the alternative section and
terminate the conditional section.

Valid comparisons are
* ==
* !=
* <
* <=
* >
* >=
* in
* not_in

# Examples

Expand Down
1 change: 1 addition & 0 deletions docs/Module/Pypower.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ past values of the `scada` global.
# See also

* [PyPower documentation](https://pypi.org/project/PYPOWER/)
* [[/Module/Pypower/Geodata]]
* [[/Module/Pypower/Load]]
* [[/Module/Pypower/Powerline]]
* [[/Module/Pypower/Powerplant]]
Expand Down
53 changes: 53 additions & 0 deletions docs/Module/Pypower/Geodata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[[/Module/Pypower/Geodata]] -- PyPower geodata object

# Synopsis

~~~
class geodata
{
char1024 file; // geodata file name
char1024 target; // geodata target class and property, e.g., CLASS::PROPERTY or OBJECT.PROPERTY
}
~~~

# Description

A `geodata` object can be used to apply values to properties of object
according to the geographic location. The selection of the value to apply is
based on the nearest location in the `geodata` file. The format of the file
is a time-series, with locations encoded using geohashes in columns, e.g.,

~~~
timestamp,9mugye,9mupxg
2018-01-01 00:00:00,10,11
2018-01-01 01:00:00,12,13
2018-01-01 02:00:00,14,15
~~~

Only double values may be applied using `geodata`.

# Caveat

Some object properties are updated after the `precommit` event that processes
geodata. Consequently, any geodata written to these objects will be
overwritten by subsequent events processed by those objects. This is notably
true for `bus` and `branch` objects. If you want to change power injections,
you should process geodata for the child objects that update them, e.g., `load`,
`powerplant`, or `powerline`.

# Example

The following example applies the values in the file `geodata_load_P.csv` to the
values of `P` is all object of class `load`.

~~~
object pypower.geodata
{
file "geodata_load_P.csv";
target "load::P";
}
~~~

# See Also

* [[Module/Pypower]]
2 changes: 1 addition & 1 deletion geodata/autotest/test_datasets.glm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define DIR=..
#endif

#if ${github_actions:-no}==no
#if ${github_actions:-no} == no
// TODO: this doesn't work on github actions because of a problems with accessing required services
#exec ${DIR:-.}/unittest.sh
#endif
1 change: 1 addition & 0 deletions module/pypower/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module_pypower_pypower_la_SOURCES += module/pypower/branch.cpp module/pypower/br
module_pypower_pypower_la_SOURCES += module/pypower/bus.cpp module/pypower/bus.h
module_pypower_pypower_la_SOURCES += module/pypower/gen.cpp module/pypower/gen.h
module_pypower_pypower_la_SOURCES += module/pypower/gencost.cpp module/pypower/gencost.h
module_pypower_pypower_la_SOURCES += module/pypower/geodata.cpp module/pypower/geodata.h
module_pypower_pypower_la_SOURCES += module/pypower/load.cpp module/pypower/load.h
module_pypower_pypower_la_SOURCES += module/pypower/powerline.cpp module/pypower/powerline.h
module_pypower_pypower_la_SOURCES += module/pypower/powerplant.cpp module/pypower/powerplant.h
Expand Down
50 changes: 50 additions & 0 deletions module/pypower/autotest/test_case14_geodata.glm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#define CASE=14
#ifexists "../case.glm"
#define DIR=..
#endif

// #set debug=TRUE
#set suppress_repeat_messages=FALSE

module pypower
{
maximum_timestep 3600;
save_case TRUE;
}

#include "${DIR:-.}/case.glm"

modify pp_bus_2.latitude 38.5;
modify pp_bus_2.longitude -122.5;

object pypower.load
{
name "load_2";
parent "pp_bus_2";
latitude 38.5;
longitude -122.5;
Vn 12.5 kV;
status ONLINE;
}

object pypower.geodata
{
file "${DIR:-.}/test_case14_geodata_P.csv";
target "load_2.P";
}

module tape
{
csv_header_type NAME;
}

object tape.recorder
{
parent "load_2";
file "test_case14_geodata_load_2_record.csv";
property "P";
}

#ifexists "../test_case14_geodata_load_2_record.csv"
#on_exit 0 diff ../test_case14_geodata_load_2_record.csv test_case14_geodata_load_2_record.csv > gridlabd.diff
#endif
4 changes: 4 additions & 0 deletions module/pypower/autotest/test_case14_geodata_P.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
timestamp,9q8vk6,9qbgh2
2020-01-01 00:00:00,10,11
2020-01-01 01:00:00,12,13
2020-01-01 02:00:00,14,15
4 changes: 4 additions & 0 deletions module/pypower/autotest/test_case14_geodata_load_2_record.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
timestamp,P
2020-01-01 00:00:00 PST,+11+0i
2020-01-01 01:00:00 PST,+13+0i
2020-01-01 02:00:00 PST,+15+0i
2 changes: 2 additions & 0 deletions module/pypower/bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ bus::bus(MODULE *module)
PT_KEYWORD, "PQREF", (enumeration)1,

PT_double, "Pd[MW]", get_Pd_offset(),
PT_OUTPUT,
PT_DESCRIPTION, "real power demand (MW)",

PT_double, "Qd[MVAr]", get_Qd_offset(),
PT_OUTPUT,
PT_DESCRIPTION, "reactive power demand (MVAr)",

PT_double, "Gs[MW]", get_Gs_offset(),
Expand Down
Loading

0 comments on commit b65b3c2

Please sign in to comment.