optiwindnet.convertingΒΆ
Conversions that cross graph kinds.
Every function here takes one kind and returns another: a site to a location
graph L, L and A to a topology S, S to a routeset G, and S
to or from its bit and terse encodings. For a variant of the same kind, see
optiwindnet.transforming.
Module ContentsΒΆ
- optiwindnet.converting.linkbits_from_S(A: networkx.Graph, S: networkx.Graph) bitarray.frozenbitarray[source]ΒΆ
Encode topology
SoverAβs canonical undirected available-links set.Terminal-terminal positions follow the lexicographic edge order cached by
make_planar_embedding(). TheR * Tfeeder positions follow in terminal-major order, with roots from-Rto-1.Amust provide its'_canonical_terminal_links'graph attribute.Smust be an undetoured topology containing only terminals and roots.
- optiwindnet.converting.S_from_linkbits(linkbits: bitarray.bitarray, A: networkx.Graph) networkx.Graph[source]ΒΆ
Decode canonical
linkbitsinto an undetoured topologyS.Uses the same terminal-link and feeder ordering as
linkbits_from_S().Amust provide its'_canonical_terminal_links'graph attribute. The bit count must matchAβs available-links set; a mismatch raisesValueError. Equal bit counts are not proof of a common origin: compareAβs'_linkset_id'with the producerβs to confirm that the bits and the graph describe the same available-links set.The result contains all
Tterminals andRroots, including isolated nodes, without node attributes. Only connectivity is recovered: loads, capacity, topology type and other solution metadata are not encoded. No feasibility validation or load calculation is performed.
- optiwindnet.converting.L_from_site(*, VertexC: numpy.ndarray, T: int, R: int, B: int = 0, border: numpy.ndarray | None = None, obstacles: list[numpy.ndarray] | None = None, name: str = '', handle: str = 'L_from_site', landscape_angle: float | None = None) networkx.Graph[source]ΒΆ
Create L from a locationβs attributes.
- Parameters:
VertexC β numpy.ndarray (V, 2) with all (x, y) coordinates (V = R + T + B)
T β int number of wtg
R β int number of oss
B β number of border and obstacle zonesβ vertices
border β array (B,) of VertexC indices that define the border (ccw)
obstacles β sequence of numpy.ndarray of VertexC indices
name β site name
handle β site identifier
- Returns:
Graph containing
N = R + Tnodes and no edges (all args become graph attributes).
- optiwindnet.converting.G_from_S(S: networkx.Graph, A: networkx.Graph) networkx.Graph[source]ΒΆ
Create G from S and A.
Graph
Scontains the topology of a routeset network (nodes only, no contours or detours).Smust have been created from the available links inA, whose contour information is used to obtain a routesetG(possibly with contours, but not with detours β use PathFinder afterward).- Warns:
UserWarning β if the topology contains links absent from the mesh.
- optiwindnet.converting.S_from_G(G: networkx.Graph) networkx.Graph[source]ΒΆ
Get
Gβs topology (contours, detours, lengths and coords are dropped).Terminal
'inflow'attributes are preserved so that recalculating loads onSuses the same terminal contributions as onG, as are the graph attributes that record the quantization of the solve ('power_per_inflow','capacity_nominal'and'power_rtol'). Declared nominal power belongs to the site and routed graphs, not the topology.If using
Sto warm-start a MILP model, call afterS_from_G():as_hooked_to_nearest()forTopology.BRANCHED;as_hooked_to_head()forTopology.RADIAL.
This makes a radial
Sfeasible and avoids a trivially suboptimal branchedS. For RINGED routesets, cycle-closing links are retained, soSpreserves the ring partition ofG.- Parameters:
G β feasible routed solution with a tree, path or ring topology.
- Returns:
Topology of
G.- Raises:
ValueError β a routed link does not form a chain between two real nodes.
- optiwindnet.converting.L_from_G(G: networkx.Graph) networkx.Graph[source]ΒΆ
Return new location with nodes and site attributes from G.
The returned location graph
Lretains only roots, nodes and basic graph attributes. All edges and remaining attributes are not carried fromG. Of the turbine power, only the declaration is kept (terminal'power'under'powers_set', otherwise'power_per_inflow'and the inflow other than one), not the quantization of the solve.- Parameters:
G β routeset graph to extract site data from.
- Returns:
Site graph (no edges) with lean attributes.