-
Notifications
You must be signed in to change notification settings - Fork 1
zz/dss_writer_edits #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2ca4063
ba3873f
9dd6e3d
a0747d0
95f7812
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| from gdm.distribution import DistributionSystem | ||
| from infrasys import Component | ||
|
|
||
|
|
||
| from ditto.writers.opendss.components.distribution_branch import DistributionBranchMapper | ||
| from ditto.enumerations import OpenDSSFileTypes | ||
|
|
||
|
|
||
| class MatrixImpedanceRecloserMapper(DistributionBranchMapper): | ||
| def __init__(self, model: Component, system: DistributionSystem): | ||
| super().__init__(model, system) | ||
|
|
||
| altdss_name = "Line_LineCode" | ||
| altdss_composition_name = "Line" | ||
| opendss_file = OpenDSSFileTypes.SWITCH_FILE.value | ||
|
|
||
| def map_equipment(self): | ||
| self.opendss_dict["LineCode"] = self.get_opendss_safe_name(self.model.equipment.name) | ||
|
|
||
| def map_is_closed(self): | ||
| # Require every phase to be enabled for the OpenDSS line to be enabled. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be a switch by default, and the is_closed be covered by in_service?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's good to question this. I did not and just copied what's here from the matrix_impedance_switch mapper. |
||
| self.opendss_dict["Switch"] = "true" | ||
|
|
||
| def map_in_service(self): | ||
| self.opendss_dict["enabled"] = self.model.in_service | ||
|
|
||
| def map_controller(self): | ||
| pass | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ def __init__(self, model: Component, system: DistributionSystem): | |
| opendss_file = OpenDSSFileTypes.TRANSFORMERS_FILE.value | ||
|
|
||
| def map_name(self): | ||
| self.opendss_dict["Name"] = self.model.name | ||
| self.opendss_dict["Name"] = self.get_opendss_safe_name(self.model.name) | ||
|
|
||
| def map_pct_no_load_loss(self): | ||
| self.opendss_dict["pctNoLoadLoss"] = self.model.pct_no_load_loss | ||
|
|
@@ -44,13 +44,20 @@ def map_windings(self): | |
| num_phases = winding.num_phases | ||
| # rated_voltage | ||
| nom_voltage = winding.rated_voltage.to("kV").magnitude | ||
| kvs.append(nom_voltage if num_phases == 1 else nom_voltage * 1.732) | ||
| voltage_type = winding.voltage_type | ||
| connection_type = winding.connection_type | ||
| nom_voltage = nom_voltage if voltage_type == "line-to-ground" else nom_voltage / 1.732 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will work for now, but we should create an issue to deal with the line-to-ground vs line-line voltage issue, so that we're really clear about how we standardize the voltage measurements in ditto or GDM. This seems like something that we should have a better long-term solution for than dividing by a magic number.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, happy to change this to at least a constant or have a function that clearly states the transformation. I think there will always need to be some wrangling at this step give how particular opendss is on where it expects L-L vs L-N |
||
| kvs.append( | ||
| nom_voltage | ||
| if num_phases == 1 and connection_type != "DELTA" | ||
| else nom_voltage * 1.732 | ||
| ) | ||
| # resistance | ||
| pctRs.append(winding.resistance) | ||
| # rated_power | ||
| kVAs.append(winding.rated_power.to("kva").magnitude) | ||
| # connection_type | ||
| conns.append(self.connection_map[winding.connection_type]) | ||
| conns.append(self.connection_map[connection_type]) | ||
| # TODO: num_phases and is_grounded aren't included | ||
| if self.model.is_center_tapped and i == len(self.model.windings): | ||
| kvs.append(nom_voltage) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,19 +22,31 @@ def map_common(self): | |
| self.opendss_dict["Units"] = "km" | ||
|
|
||
| def map_name(self): | ||
| self.opendss_dict["Name"] = self.model.name | ||
| self.opendss_dict["Name"] = self.get_opendss_safe_name(self.model.name) | ||
|
|
||
| def map_r_matrix(self): | ||
| r_matrix_ohms = self.model.r_matrix.to("ohm/km") | ||
| self.opendss_dict["RMatrix"] = r_matrix_ohms.magnitude | ||
| assert ( | ||
| abs(r_matrix_ohms.magnitude - r_matrix_ohms.T.magnitude).max() < 1e-6 | ||
| ), "RMatrix must be symmetric" | ||
| r_matrix_ohms = (r_matrix_ohms.magnitude + r_matrix_ohms.T.magnitude) / 2 | ||
| self.opendss_dict["RMatrix"] = r_matrix_ohms | ||
|
|
||
| def map_x_matrix(self): | ||
| x_matrix_ohms = self.model.x_matrix.to("ohm/km") | ||
| self.opendss_dict["XMatrix"] = x_matrix_ohms.magnitude | ||
| assert ( | ||
| abs(x_matrix_ohms.magnitude - x_matrix_ohms.T.magnitude).max() < 1e-6 | ||
| ), "XMatrix must be symmetric" | ||
| x_matrix_ohms = (x_matrix_ohms.magnitude + x_matrix_ohms.T.magnitude) / 2 | ||
| self.opendss_dict["XMatrix"] = x_matrix_ohms | ||
|
|
||
| def map_c_matrix(self): | ||
| c_matrix_nf = self.model.c_matrix.to("nanofarad/km") | ||
| self.opendss_dict["CMatrix"] = c_matrix_nf.magnitude | ||
| assert ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wondering, are these best as assertions or GDM validations?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well it's a good question. I would be fine moving this exact assert to GDM validation if we don't want non-symmetric matrices. But i'm not sure that is a restriction that needs to be in GDM- i'm sort of fine for them to exist. The reason this is adjustment is here is because altdss has a very strict rule for symmetry. Even if we were to add this as a validation to GDM, I would tend to not go so strict to avoid these floating point equality issues. And then this check would be required anyway. |
||
| abs(c_matrix_nf.magnitude - c_matrix_nf.T.magnitude).max() < 1e-6 | ||
| ), "CMatrix must be symmetric" | ||
| c_matrix_nf = (c_matrix_nf.magnitude + c_matrix_nf.T.magnitude) / 2 | ||
| self.opendss_dict["CMatrix"] = c_matrix_nf | ||
|
|
||
| def map_ampacity(self): | ||
| ampacity_amps = self.model.ampacity.to("ampere") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.