-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathPflowModelBuilder.java
More file actions
156 lines (133 loc) · 3.64 KB
/
PflowModelBuilder.java
File metadata and controls
156 lines (133 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package com.powerdata.openpa;
/*
* Copyright (c) 2016, PowerData Corporation, Incremental Systems Corporation
* All rights reserved.
* Licensed under the BSD-3 Clause License.
* See full license at https://powerdata.github.io/openpa/LICENSE.md
*/
import java.lang.reflect.Constructor;
import java.util.HashMap;
import com.powerdata.openpa.impl.ModelBuilderI;
/**
* Build Models with load options suitable by some power apps (i.e. a power
* flow)
*
* @author chris@powerdata.com
*
*/
public abstract class PflowModelBuilder extends ModelBuilderI
{
/** static translations of scheme to input class */
static HashMap<String,String> _SchemeToInputClass = new HashMap<String,String>();
/** seed the class translations with some defaults */
static
{
SetSchemeInputClass("pd3cim", "com.powerdata.pa.api.PflowPD3ModelBldr");
SetSchemeInputClass("pd2cim", "com.powerdata.pa.api.PflowPD2ModelBldr");
SetSchemeInputClass("psmfmt", "com.powerdata.openpa.PFlowPsmModelBldr");
}
/**
* Set a scheme to input class name translation.
* @param scheme
* @param pkg
*/
public static void SetSchemeInputClass(String scheme, String pkg)
{
_SchemeToInputClass.put(scheme, pkg);
}
protected boolean _flat = false;
float _leastx = 0;
boolean _correctR = false;
boolean _correctMagY = false;
boolean _doos = false;
boolean _genregterm;
/** disable branches with bad Z values */
private boolean _svcdroop = false;
/** ignore case voltage and set flat. Sets VM to 1 and VA to 0 if true */
public boolean useFlatVoltage()
{
return _flat;
}
/** ignore case voltage and set flat. Sets VM to 1 and VA to 0 if true */
public void enableFlatVoltage(boolean useflat)
{
_flat = useflat;
}
public boolean correctMagY() {return _correctMagY;}
public void enableMagYCorrection(boolean e) {_correctMagY = e;}
public boolean correctRVal(){return _correctR;}
public void enableRCorrection(boolean e) {_correctR = e;}
/**
* limit the branch reactance minimum magnitude, abs(X) > minx, defaults to
* 0 (no limit)
*/
public float getLeastX()
{
return _leastx;
}
/**
* limit the branch reactance minimum magnitude, abs(X) > minx, defaults to
* 0 (no limit)
*/
public void setLeastX(float leastx)
{
_leastx = leastx;
}
/** drop out-of-service branches */
public boolean dropOOS()
{
return _doos;
}
/** enable / disable dropping out-of-service (de-energized) branches */
public void enableDropOOS(boolean drop)
{
_doos = drop;
}
/**
* ignore case unit setpoints, and substitute case voltage at unit terminal
* bus
*/
public boolean getUnitRegOverride()
{
return _genregterm;
}
/**
* ignore case unit setpoints, and substitute case voltage at unit terminal
* bus
*/
public void setUnitRegOverride(boolean override)
{
_genregterm = override;
}
public boolean getSVCDroop()
{
return _svcdroop ;
}
public void setSVCDroop(boolean usedroop)
{
_svcdroop = usedroop;
}
/**
* Create a new PflowModelBuilder
* @param uri URI of source data
* @return ModelBuilder used to configure and build PAModel
* @throws PAModelException
*/
public static PflowModelBuilder Create(String uri) throws PAModelException
{
String[] tok = uri.split(":", 2);
String clsnm = _SchemeToInputClass.get(tok[0]);
if (clsnm == null) throw new PAModelException("Scheme not defined for Input: "+tok[0]);
try
{
Class<?> cls = Class.forName(clsnm);
Constructor<?> con = cls.getConstructor(new Class[] {String.class});
PflowModelBuilder rv = (PflowModelBuilder) con.newInstance(new Object[]{tok[1]});
return rv;
}
catch (Exception e)
{
throw new PAModelException("Scheme "+tok[0]+" "+e, e);
}
}
}