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

Commit

Permalink
Add load model fitting (#1032)
Browse files Browse the repository at this point in the history
* Add load model fitting

* Update load_model.py

* Update load_model.py

* Create load_model_config.py

* Update load_model.py

* Create load_model.glm

* Increase filter model order limits

* Update load_model.glm

* Update load_model.py

* Work progress

* Update transform.cpp

* Update transform.cpp

* Update fit_filter.py

* Update load_model.glm

* Stub support for initial conditions in filter

* Update transform.cpp

* Update .gitignore

* Update Output_message_context.md

* Update Output_message_context.md

* Update load.cpp

* Update transform.cpp

* Update load_model.glm

* Update transform.cpp

* Update load_model.glm

* Update transform.cpp

* Update fit_filter.py

* Update transform.cpp

* Update transform.cpp

* Update load_model.glm

* Update fit_filter.py

* Update fit_filter.py

* Update fit_filter.py

* Update fit_filter.py

* Work progress

* Update load.cpp

* Update transform.cpp

* Update fit_filter.py

* Update transform.cpp

* Update load_model.glm

* Update fit_filter.py

* Update test_loadshape_analog.glm

* Update transform.cpp

* Update fit_filter.py

* Update transform.cpp

* Fix to allow summing transforms to outputs

* Update transform.cpp

* Add support for clock runtime parameter

* Update Filter.md

* Update transform.cpp

* Update load_model.glm

* Update test_filter_delay.glm

* Update test_filter_constraint.glm

* Update test_filter_constraint.glm

* Update test_filter_constraint.glm

* Update test_filter_delay.glm

* Update test_filter_constraint.glm

* Finalize example of load model fitting

* Update fit_filter.py

* Update load_model.glm

Co-authored-by: Alyona Teyber <Ivanova.alyona5@gmail.com>
  • Loading branch information
David P. Chassin and aivanova5 authored Dec 24, 2021
1 parent bb8d18b commit 5dbcf69
Show file tree
Hide file tree
Showing 19 changed files with 351,872 additions and 147 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,5 @@ gldcore/converters/autotest/table2glm_input.glm
gldcore/geodata/docs/geodata.conf
gldcore/gridlabd.in
geodata.conf
gldcore/autotest/output.csv
python_extras/example/output.csv
11 changes: 10 additions & 1 deletion docs/GLM/Directive/Clock.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ clock
timezone "<specification>";
starttime "<datetime>";
stoptime "<datetime>";
runtime "<deltatime>";
}
~~~

Expand All @@ -21,9 +22,17 @@ The `clock` directive specifies how the internal clock will operate while a simu

The `timezone` property sets the time zone for the simulation. The time zone may be specified either as a ISO timezone, e.g., `PST+8PDT`, or a locale, e.g., `US/CA/San Francisco`. If the time zone is not specified the simulation will use `UTC`.

## `runtime`

The `runtime` property sets the duration of the simulation run. This will always be relative to the `starttime` and set the `stoptime` accordingly. Valid units are `s`, `m`, `h`, `d`, and `w` for seconds, minutes, hours, days, and weeks, respectively.

Note that runtime units of months and years are not supported because they are not well-defined units.

## `starttime`

The `starttime` property specifies when the simulation start. If no time zone is specified, the current time zone is used if it has been specified. Otherwise `UTC` is assumed. If no start time is specified, the current wall clock time is used. Note, `ISO8601` is supported.
The `starttime` property specifies when the simulation start. If no time zone is specified, the current time zone is used if it has been specified. Otherwise `UTC` is assumed. If no start time is specified, the current wall clock time is used. Note, `ISO8601` is supported.

Note that the parameter `timestamp` is a synonym for `starttime`.

## `stoptime`

Expand Down
16 changes: 15 additions & 1 deletion docs/GLM/Directive/Filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ filter <name>(<domain>[,<timestep>[,<timeskew>[,<option>=<value>]]]) = <polynomi

The filter directive defines a filter that can be used to connect a signal source property to a output signal property.

Filter may be used to output values to an object property of type `double`. Outputs are summed so that multiple filter may output to a single property, e.g.,

~~~
object example
{
output1 filter11(input1);
output1 filter21(input2);
output2 filter12(input1);
output2 filter22(input2);
}
~~~

Would represent a MIMO system with two inputs going to two outputs through 4 different filters with outputs summed.

## Name

Any unique alphabetic name may be used.
Expand Down Expand Up @@ -46,7 +60,7 @@ The numerator and denominator are specified as a polynomial of the form $a_n z^n
an z^n + ... + a1 z + a0
~~~

The order of the numerator must be strictly less than the order of the denominator.
The order of the numerator must be less than or equal to the order of the denominator.

# Example

Expand Down
57 changes: 56 additions & 1 deletion docs/Global/Output_message_context.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,62 @@ bash$ gridlabd --define output_message_context=ALL

# Description

Control context from which debug messages are allowed
Control context from which core debug messages are allowed. Valid message contexts are

- `AGGREGATE`: aggregation debug messages only
- `ALL`: all debug messages allowed
- `CLASS`: class debug messages only
- `CMDARG`: command line subsystem debug messages only
- `COMPARE`: compare debug messages only
- `CONVERT`: converter debug messages only
- `CREATE`: create debug messages only
- `DELTAMODE`: deltamode debug messages only
- `ENDUSE`: enduse debug messages only
- `ENVIRONMENT`: environment debug messages only
- `EXCEPTION`: exception handling debug messages only
- `EXEC`: exec debug messages only
- `FIND`: find subsystem debug messages only
- `GLOBALS`: globals debug messages only
- `GUI`: graphical user interface debug messages only
- `HTTP`: HTTP server debug messages only
- `HTTPCLIENT`: HTTP client debug messages only
- `INDEX`: index debug messages only
- `INSTANCE`: instance manager debug messages only
- `INTERPOLATE`: interpolation debug messages only
- `JOB`: job control debug messages only
- `KML`: KML interface debug messages only
- `LEGAL`: legal debug messages only
- `LINK`: link debug messages only
- `LIST`: list debug messages only
- `LOAD`: loader debug messages only
- `LOADSHAPE`: loadshape debug messages only
- `LOCALE`: locale debug messages only
- `LOCK`: memory locking debug messages only
- `MAIN`: main module debug messages only
- `MATCH`: match subsystem debug messages only
- `MATLAB`: Matlab interface debug messages only
- `MODULE`: module debug messages only
- `NONE`: no debug messages allowed
- `OBJECT`: object debug messages only
- `PROPERTY`: property debug messages only
- `PYTHON`: python module debug messages only
- `RANDOM`: random variable debug messages only
- `REALTIME`: realtime subsystem debug messages only
- `SANITIZE`: model sanitizer subsystem debug messages only
- `SAVE`: save debug messages only
- `SCHEDULE`: schedule debug messages only
- `SERVER`: server subsystem debug messages only
- `SETUP`: setup debug messages only
- `STREAM`: streaming data debug messages only
- `TEST`: testing subsystem debug messages only
- `THREADPOOL`: thread pool debug messages only
- `TIME`: time subsystem debug messages only
- `TRANSFORM`: transform subsystem debug messages only
- `UNIT`: unit manager subsystem debug messages only
- `VALIDATE`: validation subsystem debug messages only
- `VERSION`: version debug messages only
- `XCORE`: X11 core debug messages only
- `XML`: XML interface debug messages only

# Example

Expand Down
29 changes: 26 additions & 3 deletions gldcore/autotest/test_filter_constraint.glm
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
clock {
timezone PST+8PDT;
starttime '2000-01-01 00:00:00 PST';
stoptime '2000-01-01 01:00:00 PST';
stoptime '2000-01-02 00:00:00 PST';
}

#set randomseed=1
filter delay(z,5min,10s,resolution=8,minimum=-2.5,maximum=2.5) = 1/z;
class from {
randomvar value;
Expand All @@ -27,5 +27,28 @@ object multi_recorder {
file output.csv;
interval -1;
property "from:value,to:value";
#warning no assert in autotest
}

module assert;
object assert {
parent to;
start '2000-01-01 00:00:00 PST';
stop '2000-01-01 00:05:09 PST';
target value;
relation ==;
value 0.0;
within 1e-4;
}
object assert {
parent to;
start '2000-01-01 00:05:10 PST';
stop '2000-01-01 00:10:09 PST';
target value;
relation ==;
value +0.443108;
within 1e-4;
}

#set debug=TRUE
#set output_message_context=TRANSFORM
#set suppress_repeat_messages=FALSE
29 changes: 27 additions & 2 deletions gldcore/autotest/test_filter_delay.glm
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
clock {
timezone PST+8PDT;
starttime '2000-01-01 00:00:00 PST';
stoptime '2000-01-01 01:00:00 PST';
stoptime '2000-01-02 00:00:00 PST';
}
filter delay(z,5min,10s) = 1/z;
#set randomseed=1
filter delay(z,5min) = 1/z;
class from {
randomvar value;
}
Expand All @@ -27,5 +28,29 @@ object multi_recorder {
property "from:value,to:value";
}

module assert;
object assert {
parent to;
start '2000-01-01 00:00:00 PST';
stop '2000-01-01 00:04:59 PST';
target value;
relation ==;
value 0.0;
within 1e-4;
}
object assert {
parent to;
start '2000-01-01 00:05:00 PST';
stop '2000-01-01 00:09:59 PST';
target value;
relation ==;
value +0.443108;
within 1e-4;
}

#set glm_save_options=MINIMAL
#set savefile=gridlabd.glm

#set output_message_context=TRANSFORM
#set suppress_repeat_messages=FALSE
#set debug=TRUE
6 changes: 5 additions & 1 deletion gldcore/autotest/test_loadshape_analog.glm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
clock {
timezone "PST+8PDT";
starttime "2020-01-01 00:00:00 PST";
stoptime "2021-01-01 00:00:00 PST";
stoptime "2020-01-02 00:00:00 PST";
}

module tape;
Expand Down Expand Up @@ -82,6 +82,7 @@ object test_loadshape
relation "==";
value 1.0;
within 0.00001;
hold 3600s;
};
}

Expand All @@ -95,6 +96,7 @@ object test_loadshape
relation "==";
value 0.5;
within 0.00001;
hold 3600s;
};
}

Expand All @@ -108,6 +110,7 @@ object test_loadshape
relation "==";
value 0.04167;
within 0.00001;
hold 3600s;
};
}

Expand All @@ -121,6 +124,7 @@ object test_loadshape
relation "==";
value 0.04167;
within 0.00001;
hold 3600s;
};
}

Loading

0 comments on commit 5dbcf69

Please sign in to comment.