|
| 1 | +/** |
| 2 | + * @file newengland.cpp |
| 3 | + * @author Luke Lowery (lukel@tamu.edu) |
| 4 | + * @author Adam Birchfield (abirchfield@tamu.edu) |
| 5 | + * @author Slaven Peles (peless@ornl.gov) |
| 6 | + * @brief Example running the New England IEEE 39-Bus Case |
| 7 | + * |
| 8 | + * Simulates a New England IEEE 39-Bus with Genrou 6th order generator model and |
| 9 | + * compares results with data generated for the same system by Poweworld. |
| 10 | + * |
| 11 | + */ |
| 12 | +#include "newengland.hpp" |
| 13 | + |
| 14 | +#include <ctime> |
| 15 | +#include <filesystem> |
| 16 | +#include <iostream> |
| 17 | + |
| 18 | +#include <GridKit/Model/PhasorDynamics/ComponentLibrary.hpp> |
| 19 | +#include <GridKit/Model/PhasorDynamics/SystemModel.hpp> |
| 20 | +#include <GridKit/Model/PhasorDynamics/SystemModelData.hpp> |
| 21 | +#include <GridKit/Solver/Dynamic/Ida.hpp> |
| 22 | +#include <GridKit/Utilities/Testing.hpp> |
| 23 | + |
| 24 | +int main(int argc, const char* argv[]) |
| 25 | +{ |
| 26 | + using namespace GridKit::PhasorDynamics; |
| 27 | + using namespace AnalysisManager::Sundials; |
| 28 | + |
| 29 | + using scalar_type = double; |
| 30 | + // using real_type = double; |
| 31 | + using index_type = size_t; |
| 32 | + |
| 33 | + // Read Input JSON File |
| 34 | + std::filesystem::path input_file; |
| 35 | + if (argc < 2) |
| 36 | + { |
| 37 | + if (std::filesystem::exists("newengland.json")) |
| 38 | + { |
| 39 | + input_file = std::filesystem::current_path() / "newengland.json"; |
| 40 | + } |
| 41 | + else |
| 42 | + { |
| 43 | + std::cout << "\n" |
| 44 | + "ERROR: No input file found or provided.\n" |
| 45 | + "\n" |
| 46 | + "Usage:\n" |
| 47 | + " newengland <json-input-file>\n" |
| 48 | + "\n" |
| 49 | + "Please provide a JSON input file as a positional command-line \n" |
| 50 | + "argument.\n" |
| 51 | + "\n" |
| 52 | + "By default this example will look for \"newengland.json\" in the \n" |
| 53 | + "current working directory and use that if found.\n" |
| 54 | + "\n"; |
| 55 | + exit(1); |
| 56 | + } |
| 57 | + } |
| 58 | + else |
| 59 | + { |
| 60 | + input_file = argv[1]; |
| 61 | + } |
| 62 | + |
| 63 | + std::cout << "Example: newengland\n"; |
| 64 | + std::cout << "Input file: " << input_file << '\n'; |
| 65 | + |
| 66 | + // Parse Model Data |
| 67 | + auto data = parseSystemModelData(input_file); |
| 68 | + |
| 69 | + // Instantiate System Model |
| 70 | + SystemModel<scalar_type, index_type> sys(data); |
| 71 | + sys.allocate(); |
| 72 | + |
| 73 | + int status = 0; |
| 74 | + return status; |
| 75 | +} |
0 commit comments