本文整理了Java中com.powsybl.iidm.network.Generator.getTerminal()
方法的一些代码示例,展示了Generator.getTerminal()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Generator.getTerminal()
方法的具体详情如下:
包路径:com.powsybl.iidm.network.Generator
类名称:Generator
方法名:getTerminal
暂无
代码示例来源:origin: itesla/ipst
@Override
public void visitGenerator(Generator generator) {
terminals.add(generator.getTerminal());
}
代码示例来源:origin: itesla/ipst
private double newP(Generator generator, double deltaP, double participationFactor, double totalPartecipationFactor) {
return generator.getTerminal().getP() - deltaP * participationFactor / totalPartecipationFactor;
}
代码示例来源:origin: com.powsybl/powsybl-action-util
@Override
public double initialValue(Network n) {
Objects.requireNonNull(n);
Generator g = n.getGenerator(id);
return g != null && !Double.isNaN(g.getTerminal().getP()) ? g.getTerminal().getP() : 0;
}
代码示例来源:origin: itesla/ipst
public static boolean isConnected(Generator generator) {
Bus generatorBus = generator.getTerminal().getBusBreakerView().getBus();
double voltage = getV(generator.getTerminal());
if (generatorBus != null && !Double.isNaN(voltage)) {
// generator is connected
return true;
}
return false;
}
代码示例来源:origin: itesla/ipst
private boolean filteredGenerator(Generator g, boolean isFiltered) {
if (isFiltered) {
if (!Double.isNaN(g.getTerminal().getP()) && ((-g.getTerminal().getP() > g.getMaxP()) || (-g.getTerminal().getP() < g.getMinP()))) {
return true;
}
}
return false;
}
代码示例来源:origin: itesla/ipst
private boolean filteredGenerator(Generator g) {
if (configExport.getGensPQfilter()) {
if (!Double.isNaN(g.getTerminal().getP()) && ((-g.getTerminal().getP() > g.getMaxP()) || (-g.getTerminal().getP() < g.getMinP()))) {
return true;
}
}
return false;
}
代码示例来源:origin: com.powsybl/powsybl-iidm-api
public static void printGeneratorsSetpointDiff(Network network, Logger logger) {
for (Generator g : network.getGenerators()) {
double dp = Math.abs(g.getTerminal().getP() + g.getTargetP());
double dq = Math.abs(g.getTerminal().getQ() + g.getTargetQ());
double dv = Math.abs(g.getTerminal().getBusBreakerView().getConnectableBus().getV() - g.getTargetV());
if (dp > 1 || dq > 5 || dv > 0.1) {
logger.warn("Generator {}: ({}, {}, {}) ({}, {}, {}) -> ({}, {}, {})", g.getId(),
dp, dq, dv,
-g.getTargetP(), -g.getTargetQ(), g.getTargetV(),
g.getTerminal().getP(), g.getTerminal().getQ(), g.getTerminal().getBusBreakerView().getConnectableBus().getV());
}
}
}
代码示例来源:origin: itesla/ipst
@Override
public void modify(Network network, ComputationManager computationManager) {
Generator g = network.getGenerator(generatorId);
if (g == null) {
throw new PowsyblException("Generator '" + generatorId + "' not found");
}
g.getTerminal().connect();
}
代码示例来源:origin: itesla/ipst
/**
* @param writerMo
* @param modContext
* @param modelicaModelsList
* @param modelicaSim
* @param sourceSim
* @throws IOException
*/
private void exportGeneratorsAsFixedInjections(Writer writerMo, ModExportContext modContext, List<String> modelicaModelsList, SimulatorInst modelicaSim, SimulatorInst sourceSim) throws IOException {
// Export Generators as Fixed Inyections
if ((generatorsInyections.size() != 0) && (!generatorsInyections.isEmpty())) {
LOGGER.info("EXPORTING GENERATORS AS FIXED INYECTIONS");
for (Generator generator : generatorsInyections) {
LOGGER.info("\t Exporting generator inyection " + generator.getId());
ConnectBusInfo busInfo = findBus(generator.getTerminal(), generator.getId());
GeneratorRecord generatorRecord = ModelConverter.getModelicaRecord(generator, busInfo, modContext, _ddbManager, modelicaSim, sourceSim, true, SNREF, this.paramsDictionary, this._sourceEngine);
this.addRecord(generatorRecord, writerMo, modContext, _ddbManager, modelicaSim);
}
}
}
代码示例来源:origin: com.powsybl/powsybl-action-util
private static void connectGenerator(Generator g) {
Terminal t = g.getTerminal();
t.connect();
if (g.isVoltageRegulatorOn()) {
Bus bus = t.getBusView().getBus();
if (bus != null) {
// set voltage setpoint to the same as other generators connected to the bus
double targetV = bus.getGeneratorStream().findFirst().map(Generator::getTargetV).orElse(Double.NaN);
// if no other generator connected to the bus, set voltage setpoint to network voltage
if (Double.isNaN(targetV) && !Double.isNaN(bus.getV())) {
g.setTargetV(bus.getV());
}
}
}
LOGGER.info("Connecting {}", g.getId());
}
}
代码示例来源:origin: itesla/ipst
private static void extractGeneratorsData(Network network, NetworkData networkData) {
for (Generator generator : network.getGenerators()) {
networkData.addGeneratorData(new GeneratorData(generator.getId(),
(generator.getTerminal().getBusBreakerView().getBus() != null)
? generator.getTerminal().getBusBreakerView().getBus().getId()
: generator.getTerminal().getBusBreakerView().getConnectableBus().getId(),
generator.getTerminal().getBusBreakerView().getBus() != null,
apparentPower(generator.getTerminal()),
generator.getTerminal().getP(),
generator.getTerminal().getQ(),
generator.getRatedS(),
generator.getReactiveLimits().getMaxQ(generator.getTargetP()),
generator.getReactiveLimits().getMinQ(generator.getTargetP()))
// generator.getReactiveLimits().getMaxQ(generator.getTerminal().getP()),
// generator.getReactiveLimits().getMinQ(generator.getTerminal().getP()))
);
}
}
代码示例来源:origin: itesla/ipst
public static boolean isRedispatchable(Generator generator, float redispatchLimitsPercentage) {
return (generator.getTerminal().getBusBreakerView().getBus() != null) // is connected
&& (generator.getEnergySource() == EnergySource.HYDRO || generator.getEnergySource() == EnergySource.THERMAL) // is hydro or thermal
&& (generator.getTerminal().getP() < 0) // inject power
&& (generator.isVoltageRegulatorOn()) // has voltage regulator on
&& (generator.getTargetP() <= getRedispatchPMax(generator, redispatchLimitsPercentage)
&& generator.getTargetP() >= getRedispatchPMin(generator, redispatchLimitsPercentage)); // target P is within redispatch limits
//&& (generator.getTargetP() <= generator.getMaxP() && generator.getTargetP() >= generator.getMinP()) // target P is within limits
}
代码示例来源:origin: com.powsybl/powsybl-ampl-converter
public AmplNetworkReader readGenerators() throws IOException {
// Bug fix, to avoid generators out of main cc to have a different target voltage while connected to same bus (Eurostag check)
// In that case it will not be part of result file, so not overwritten. So first reset all target voltages to nominal voltage
for (Generator g : network.getGenerators()) {
g.setTargetV(g.getTerminal().getVoltageLevel().getNominalV());
}
read("_generators", 9, this::readGenerator);
return this;
}
代码示例来源:origin: com.powsybl/powsybl-action-util
@Override
public double scale(Network n, double asked) {
Objects.requireNonNull(n);
Generator g = n.getGenerator(id);
double done = 0;
if (g != null) {
Terminal t = g.getTerminal();
if (!t.isConnected()) {
connectGenerator(g);
}
done = Math.min(asked, g.getMaxP() - g.getTargetP());
double oldTargetP = g.getTargetP();
g.setTargetP(g.getTargetP() + done);
LOGGER.info("Change active power setpoint of {} from {} to {} (pmax={})",
g.getId(), oldTargetP, g.getTargetP(), g.getMaxP());
} else {
LOGGER.warn("Generator {} not found", id);
}
return done;
}
代码示例来源:origin: com.powsybl/powsybl-iidm-xml-converter
@Override
protected void writeSubElements(Generator g, VoltageLevel vl, NetworkXmlWriterContext context) throws XMLStreamException {
if (g.getRegulatingTerminal() != null
&& !Objects.equals(g.getRegulatingTerminal().getBusBreakerView().getConnectableBus(),
g.getTerminal().getBusBreakerView().getConnectableBus())) {
writeTerminalRef(g.getRegulatingTerminal(), context, "regulatingTerminal");
}
ReactiveLimitsXml.INSTANCE.write(g, context);
}
代码示例来源:origin: com.powsybl/powsybl-iidm-xml-converter
@Override
protected void readSubElements(Generator g, NetworkXmlReaderContext context) throws XMLStreamException {
readUntilEndRootElement(context.getReader(), () -> {
switch (context.getReader().getLocalName()) {
case "regulatingTerminal":
String id = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "id"));
String side = context.getReader().getAttributeValue(null, "side");
context.getEndTasks().add(() -> g.setRegulatingTerminal(readTerminalRef(g.getTerminal().getVoltageLevel().getSubstation().getNetwork(), id, side)));
break;
case "reactiveCapabilityCurve":
case "minMaxReactiveLimits":
ReactiveLimitsXml.INSTANCE.read(g, context);
break;
default:
super.readSubElements(g, context);
}
});
}
}
代码示例来源:origin: com.powsybl/powsybl-iidm-xml-converter
@Override
protected void writeRootElementAttributes(Generator g, VoltageLevel vl, NetworkXmlWriterContext context) throws XMLStreamException {
context.getWriter().writeAttribute("energySource", g.getEnergySource().name());
XmlUtil.writeDouble("minP", g.getMinP(), context.getWriter());
XmlUtil.writeDouble("maxP", g.getMaxP(), context.getWriter());
XmlUtil.writeDouble("ratedS", g.getRatedS(), context.getWriter());
context.getWriter().writeAttribute("voltageRegulatorOn", Boolean.toString(g.isVoltageRegulatorOn()));
XmlUtil.writeDouble("targetP", g.getTargetP(), context.getWriter());
XmlUtil.writeDouble("targetV", g.getTargetV(), context.getWriter());
XmlUtil.writeDouble("targetQ", g.getTargetQ(), context.getWriter());
writeNodeOrBus(null, g.getTerminal(), context);
writePQ(null, g.getTerminal(), context.getWriter());
}
代码示例来源:origin: com.powsybl/powsybl-iidm-api
private static void addGenerators(Network network, ConnectedPower balanceMainCC, ConnectedPower balanceOtherCC) {
for (Generator g : network.getGenerators()) {
Terminal.BusBreakerView view = g.getTerminal().getBusBreakerView();
if (view.getBus() != null) {
if (view.getBus().isInMainConnectedComponent()) {
balanceMainCC.connectedMaxGeneration += g.getMaxP();
balanceMainCC.connectedGeneration += g.getTargetP();
balanceMainCC.connectedGenerators.add(g.getId());
} else {
balanceOtherCC.connectedMaxGeneration += g.getMaxP();
balanceOtherCC.connectedGeneration += g.getTargetP();
balanceOtherCC.connectedGenerators.add(g.getId());
}
} else {
if (view.getConnectableBus().isInMainConnectedComponent()) {
balanceMainCC.disconnectedMaxGeneration += g.getMaxP();
balanceMainCC.disconnectedGeneration += g.getTargetP();
balanceMainCC.disconnectedGenerators.add(g.getId());
} else {
balanceOtherCC.disconnectedMaxGeneration += g.getMaxP();
balanceOtherCC.disconnectedGeneration += g.getTargetP();
balanceOtherCC.disconnectedGenerators.add(g.getId());
}
}
}
}
代码示例来源:origin: com.powsybl/powsybl-ampl-converter
private Void readGenerator(String[] tokens) {
int num = Integer.parseInt(tokens[1]);
int busNum = Integer.parseInt(tokens[2]);
boolean vregul = Boolean.parseBoolean(tokens[3]);
double targetV = readDouble(tokens[4]);
double targetP = readDouble(tokens[5]);
double targetQ = readDouble(tokens[6]);
double p = readDouble(tokens[7]);
double q = readDouble(tokens[8]);
String id = mapper.getId(AmplSubset.GENERATOR, num);
Generator g = network.getGenerator(id);
if (g == null) {
throw new AmplException("Invalid generator id '" + id + "'");
}
g.setVoltageRegulatorOn(vregul);
g.setTargetP(targetP);
g.setTargetQ(targetQ);
Terminal t = g.getTerminal();
t.setP(p).setQ(q);
double vb = t.getVoltageLevel().getNominalV();
g.setTargetV(targetV * vb);
busConnection(t, busNum);
return null;
}
代码示例来源:origin: com.powsybl/powsybl-iidm-xml-converter
@Override
protected Generator readRootElementAttributes(GeneratorAdder adder, NetworkXmlReaderContext context) {
EnergySource energySource = EnergySource.valueOf(context.getReader().getAttributeValue(null, "energySource"));
double minP = XmlUtil.readDoubleAttribute(context.getReader(), "minP");
double maxP = XmlUtil.readDoubleAttribute(context.getReader(), "maxP");
double ratedS = XmlUtil.readOptionalDoubleAttribute(context.getReader(), "ratedS");
boolean voltageRegulatorOn = XmlUtil.readBoolAttribute(context.getReader(), "voltageRegulatorOn");
double targetP = XmlUtil.readDoubleAttribute(context.getReader(), "targetP");
double targetV = XmlUtil.readOptionalDoubleAttribute(context.getReader(), "targetV");
double targetQ = XmlUtil.readOptionalDoubleAttribute(context.getReader(), "targetQ");
readNodeOrBus(adder, context);
Generator g = adder.setEnergySource(energySource)
.setMinP(minP)
.setMaxP(maxP)
.setRatedS(ratedS)
.setVoltageRegulatorOn(voltageRegulatorOn)
.setTargetP(targetP)
.setTargetV(targetV)
.setTargetQ(targetQ)
.add();
readPQ(null, g.getTerminal(), context.getReader());
return g;
}
内容来源于网络,如有侵权,请联系作者删除!