forked from NREL/hive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a getting started and customize page to docs
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Customize | ||
|
||
In addition to using hive as a command line application to run a simulation, you can also use hive as a library for co-simulation or you can extend the existing control logic. | ||
|
||
## Co-Simulation | ||
|
||
Co-simulation can be done using the `nrel.hive.app.hive_cosim` module. | ||
|
||
That module exposes a `crank` function that takes in a RunnerPayload and an integer that defines how many time steps should be run and returns a `CrankResult` object that includes the updated RunnerPayload and its sim time. At this point, you can examine the simulation state and decide what to do next, continuing in this fashion. | ||
|
||
## Custom Control Logic | ||
|
||
Adding custom control logic can be done by creating a sub class for the `InstructionGenerator` class and overriding the `generate_instructions` method. You can then inject the control module into the simulation at load time using the `load_scenario` function and then, at crank step, you can optionally update your custom control object by getting it with the `get_instruction_generator` function, modifying it and putting it back into the simulation with `update_instruction_generator`. | ||
|
||
## Example | ||
|
||
See the [cosim_custom_dispatcher.py](https://github.com/NREL/hive/blob/main/examples/cosim_custom_dispatcher.py) file for an example of using custom control logic with the co-simulation API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters