parent
8827f9e6c8
commit
8397571c11
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
|
||||
* Released under the modified BSD license. See COPYING.md for more details.
|
||||
*/
|
||||
|
||||
import { TEST_DATA_1, TEST_DATA_BLANK } from "../fixtures.test";
|
||||
import assert from "node:assert";
|
||||
import { createProfiledUnit } from "./profiledUnitOps";
|
||||
|
||||
test("createUnit", () => {
|
||||
const [newScenario, err] = createProfiledUnit(TEST_DATA_1);
|
||||
assert(err === null);
|
||||
assert.deepEqual(newScenario.Generators, {
|
||||
pu1: {
|
||||
Bus: "b1",
|
||||
Type: "Profiled",
|
||||
"Cost ($/MW)": 12.5,
|
||||
"Maximum power (MW)": [10, 12, 13, 15, 20],
|
||||
"Minimum power (MW)": [0, 0, 0, 0, 0],
|
||||
},
|
||||
pu2: {
|
||||
Bus: "b1",
|
||||
Type: "Profiled",
|
||||
"Cost ($/MW)": 0,
|
||||
"Maximum power (MW)": [0, 0, 0, 0, 0],
|
||||
"Minimum power (MW)": [0, 0, 0, 0, 0],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("createUnit with blank file", () => {
|
||||
const [newScenario, err] = createProfiledUnit(TEST_DATA_BLANK);
|
||||
assert(err !== null);
|
||||
assert.equal(err.message, "Profiled unit requires an existing bus.");
|
||||
});
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
|
||||
* Released under the modified BSD license. See COPYING.md for more details.
|
||||
*/
|
||||
|
||||
import { UnitCommitmentScenario } from "../fixtures";
|
||||
import { generateTimeslots } from "../../components/Common/Forms/DataTable";
|
||||
import { generateUniqueName } from "./busOperations";
|
||||
import { ValidationError } from "../Validation/validate";
|
||||
|
||||
export const createProfiledUnit = (
|
||||
scenario: UnitCommitmentScenario,
|
||||
): [UnitCommitmentScenario, ValidationError | null] => {
|
||||
const busNames = Object.keys(scenario.Buses);
|
||||
if (busNames.length === 0) {
|
||||
return [scenario, { message: "Profiled unit requires an existing bus." }];
|
||||
}
|
||||
const timeslots = generateTimeslots(scenario);
|
||||
const name = generateUniqueName(scenario.Generators, "pu");
|
||||
return [
|
||||
{
|
||||
...scenario,
|
||||
Generators: {
|
||||
...scenario.Generators,
|
||||
[name]: {
|
||||
Bus: busNames[0]!,
|
||||
Type: "Profiled",
|
||||
"Cost ($/MW)": 0,
|
||||
"Minimum power (MW)": Array(timeslots.length).fill(0),
|
||||
"Maximum power (MW)": Array(timeslots.length).fill(0),
|
||||
},
|
||||
},
|
||||
},
|
||||
null,
|
||||
];
|
||||
};
|
Loading…
Reference in new issue