No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
da3d2d8
... +60 ...
06d7494
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
31 | 31 | polys.append(RegularPolygon(centroid_tri1, numVertices=3, radius=size, orientation=-angle, |
|
32 | 32 | ec=col, fc=face_col, lw=lw)) |
|
33 | 33 | polys.append(RegularPolygon(centroid_tri2, numVertices=3, radius=size, |
|
34 | - | orientation=-angle+np.pi/3, ec=col, fc=face_col, lw=lw)) |
|
34 | + | orientation=-angle + np.pi / 3, ec=col, fc=face_col, lw=lw)) |
|
35 | 35 | lines.append([p1, p1 + diff / 2 - vec_size / 2 * 3]) |
|
36 | 36 | lines.append([p2, p1 + diff / 2 + vec_size / 2 * 3]) |
|
37 | 37 | return lines, polys, {"filled"} |
45 | 45 | for geodata, col in zip(coords, colors): |
|
46 | 46 | p1, p2 = np.array(geodata[0]), np.array(geodata[-1]) |
|
47 | 47 | diff = p2 - p1 |
|
48 | - | m = 3*size/4 |
|
49 | - | direc= diff/np.sqrt(diff[0]**2+diff[1]**2) |
|
48 | + | m = 3 * size / 4 |
|
49 | + | direc = diff / np.sqrt(diff[0] ** 2 + diff[1] ** 2) |
|
50 | 50 | normal = np.array([-direc[1], direc[0]]) |
|
51 | - | path1 = (p1 + diff / 2+ direc *m/2) + normal * (size * 9 / 8) |
|
52 | - | path2 = p1 + diff / 2 + direc *m / 2 |
|
51 | + | path1 = (p1 + diff / 2 + direc * m / 2) + normal * (size * 9 / 8) |
|
52 | + | path2 = p1 + diff / 2 + direc * m / 2 |
|
53 | 53 | path3 = p1 + diff / 2 + normal * size / 3 |
|
54 | - | path4 = p1 + diff / 2 - direc *m/2 |
|
55 | - | path5 = (p1 + diff / 2- direc *m/2) + normal * (size * 9 / 8) |
|
56 | - | path =[path1, path2, path3, path4, path5] |
|
57 | - | radius = size #np.sqrt(diff[0]**2+diff[1]**2)/15 |
|
54 | + | path4 = p1 + diff / 2 - direc * m / 2 |
|
55 | + | path5 = (p1 + diff / 2 - direc * m / 2) + normal * (size * 9 / 8) |
|
56 | + | path = [path1, path2, path3, path4, path5] |
|
57 | + | radius = size # np.sqrt(diff[0]**2+diff[1]**2)/15 |
|
58 | 58 | ||
59 | 59 | pa = Path(path) |
|
60 | 60 | polys.append(Circle(p1 + diff / 2, radius=radius, edgecolor=col, facecolor="w", lw=lw)) |
111 | 111 | diff = p2 - p1 |
|
112 | 112 | angle = np.arctan2(*diff) |
|
113 | 113 | vec_size = _rotate_dim2(np.array([0, size]), angle) |
|
114 | - | line1 = _rotate_dim2(np.array([0, size * np.sqrt(2)]), angle - np.pi/4) |
|
115 | - | line2 = _rotate_dim2(np.array([0, size * np.sqrt(2)]), angle + np.pi/4) |
|
114 | + | line1 = _rotate_dim2(np.array([0, size * np.sqrt(2)]), angle - np.pi / 4) |
|
115 | + | line2 = _rotate_dim2(np.array([0, size * np.sqrt(2)]), angle + np.pi / 4) |
|
116 | 116 | radius = size |
|
117 | 117 | ||
118 | 118 | polys.append(Circle(p1 + diff / 2, radius=radius, edgecolor=col, facecolor='w', lw=lw)) |
|
119 | 119 | ||
120 | - | lines.append([p1+diff/2+vec_size, p1+diff/2-vec_size+line1]) |
|
121 | - | lines.append([p1+diff/2+vec_size, p1+diff/2-vec_size+line2]) |
|
120 | + | lines.append([p1 + diff / 2 + vec_size, p1 + diff / 2 - vec_size + line1]) |
|
121 | + | lines.append([p1 + diff / 2 + vec_size, p1 + diff / 2 - vec_size + line2]) |
|
122 | 122 | ||
123 | 123 | lines.append([p1, p1 + diff / 2 - vec_size]) |
|
124 | 124 | lines.append([p2, p1 + diff / 2 + vec_size]) |
|
125 | 125 | return lines, polys, {} |
|
126 | + | ||
127 | + | ||
128 | + | def pressure_control_patches(coords, size, **kwargs): |
|
129 | + | polys, lines = list(), list() |
|
130 | + | edgecolor = kwargs.pop('patch_edgecolor') |
|
131 | + | colors = get_color_list(edgecolor, len(coords)) |
|
132 | + | lw = kwargs.get("linewidths", 2.) |
|
133 | + | for geodata, col in zip(coords, colors): |
|
134 | + | p1, p2 = np.array(geodata[0]), np.array(geodata[-1]) |
|
135 | + | diff = p2 - p1 |
|
136 | + | angle = np.arctan2(*diff) |
|
137 | + | vec_size = _rotate_dim2(np.array([0, size]), angle) |
|
138 | + | vec_size_or = _rotate_dim2(np.array([0, size * 1.2 / 2]), angle + np.pi / 2) |
|
139 | + | pll = p1 + diff / 2 - vec_size + vec_size_or |
|
140 | + | plr = p1 + diff / 2 - vec_size - vec_size_or |
|
141 | + | pul = p1 + diff / 2 + vec_size + vec_size_or/3 |
|
142 | + | pur = p1 + diff / 2 + vec_size - vec_size_or/3 |
|
143 | + | ||
144 | + | polys.append(Rectangle(pll, 2 * size, size * 1.2, angle=np.rad2deg(-angle + np.pi/2), |
|
145 | + | edgecolor=col, facecolor='w', lw=lw)) |
|
146 | + | ||
147 | + | lines.append([p1, p1 + diff / 2 - vec_size]) |
|
148 | + | lines.append([p2, p1 + diff / 2 + vec_size]) |
|
149 | + | ||
150 | + | lines.append([pll, pul]) |
|
151 | + | lines.append([plr, pur]) |
|
152 | + | ||
153 | + | return lines, polys, {} |
8 | 8 | _create_node_element_collection, _create_line2d_collection, _create_complex_branch_collection, \ |
|
9 | 9 | add_cmap_to_collection, coords_from_node_geodata |
|
10 | 10 | from pandapower.plotting.patch_makers import load_patches, ext_grid_patches |
|
11 | - | from pandapipes.plotting.patch_makers import valve_patches, source_patches, heat_exchanger_patches,\ |
|
12 | - | pump_patches |
|
11 | + | from pandapipes.plotting.patch_makers import valve_patches, source_patches, heat_exchanger_patches, \ |
|
12 | + | pump_patches, pressure_control_patches |
|
13 | 13 | from pandapower.plotting.plotting_toolbox import get_index_array |
|
14 | 14 | ||
15 | 15 | try: |
490 | 490 | patch_edgecolor=patch_edgecolor, line_color=line_color, **kwargs) |
|
491 | 491 | ||
492 | 492 | return lc, pc |
|
493 | + | ||
494 | + | ||
495 | + | def create_pressure_control_collection(net, pcs=None, table_name='press_control', |
|
496 | + | size=5., junction_geodata=None, |
|
497 | + | color='k', infofunc=None, picker=False, **kwargs): |
|
498 | + | """ |
|
499 | + | Creates a matplotlib patch collection of pandapipes junction-junction valves. Valves are |
|
500 | + | plotted in the center between two junctions with a "helper" line (dashed and thin) being drawn |
|
501 | + | between the junctions as well. |
|
502 | + | ||
503 | + | :param net: The pandapipes network |
|
504 | + | :type net: pandapipesNet |
|
505 | + | :param valves: The valves for which the collections are created. If None, all valves which have\ |
|
506 | + | entries in the respective junction geodata will be plotted. |
|
507 | + | :type valves: list, default None |
|
508 | + | :param size: Patch size |
|
509 | + | :type size: float, default 5. |
|
510 | + | :param junction_geodata: Coordinates to use for plotting. If None, net["junction_geodata"] is used. |
|
511 | + | :type junction_geodata: pandas.DataFrame, default None |
|
512 | + | :param colors: Color or list of colors for every valve |
|
513 | + | :type colors: iterable, float, default None |
|
514 | + | :param infofunc: infofunction for the patch element |
|
515 | + | :type infofunc: function, default None |
|
516 | + | :param picker: Picker argument passed to the patch collection |
|
517 | + | :type picker: bool, default False |
|
518 | + | :param fill_closed: If True, valves with parameter opened == False will be filled and those\ |
|
519 | + | with opened == True will have a white facecolor. Vice versa if False. |
|
520 | + | :type fill_closed: bool, default True |
|
521 | + | :param kwargs: Keyword arguments are passed to the patch function |
|
522 | + | :return: lc - line collection, pc - patch collection |
|
523 | + | ||
524 | + | """ |
|
525 | + | pcs = get_index_array(pcs, net[table_name].index) |
|
526 | + | pc_table = net[table_name].loc[pcs] |
|
527 | + | ||
528 | + | coords, pcs_with_geo = coords_from_node_geodata( |
|
529 | + | pcs, pc_table.from_junction.values, pc_table.to_junction.values, |
|
530 | + | junction_geodata if junction_geodata is not None else net["junction_geodata"], table_name, |
|
531 | + | "Junction") |
|
532 | + | ||
533 | + | if len(pcs_with_geo) == 0: |
|
534 | + | return None |
|
535 | + | ||
536 | + | linewidths = kwargs.pop("linewidths", 2.) |
|
537 | + | linewidths = kwargs.pop("linewidth", linewidths) |
|
538 | + | linewidths = kwargs.pop("lw", linewidths) |
|
539 | + | ||
540 | + | infos = list(np.repeat([infofunc(i) for i in range(len(pcs_with_geo))], 2)) \ |
|
541 | + | if infofunc is not None else [] |
|
542 | + | lc, pc = _create_complex_branch_collection(coords, pressure_control_patches, size, infos, |
|
543 | + | picker=picker, linewidths=linewidths, |
|
544 | + | patch_edgecolor=color, line_color=color, |
|
545 | + | **kwargs) |
|
546 | + | ||
547 | + | return lc, pc |
|
548 | + |
101 | 101 | ||
102 | 102 | :param net: The pandapipes network |
|
103 | 103 | :type net: pandapipesNet |
|
104 | - | :param branch_component_pit: |
|
105 | - | :type branch_component_pit: |
|
104 | + | :param branch_pit: |
|
105 | + | :type branch_pit: |
|
106 | 106 | :param node_pit: |
|
107 | 107 | :type node_pit: |
|
108 | 108 | :param idx_lookups: |
201 | 201 | mass_flow_dv = rho * branch_component_pit[:, AREA] |
|
202 | 202 | branch_component_pit[:, JAC_DERIV_DV_NODE] = mass_flow_dv |
|
203 | 203 | branch_component_pit[:, LOAD_VEC_NODES] = mass_flow_dv * v_init |
|
204 | + | return branch_component_pit |
|
204 | 205 | ||
205 | 206 | @classmethod |
|
206 | 207 | def calculate_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): |
370 | 371 | _sum_by_group(idx_pit, branch_pit[:, LAMBDA], branch_pit[:, RE]) |
|
371 | 372 | res_table["lambda"].values[placement_table] = lambda_sum / internal_pipes |
|
372 | 373 | res_table["reynolds"].values[placement_table] = reynolds_sum / internal_pipes |
|
374 | + | return placement_table, res_table, branch_pit, node_pit |
1 | + | # Copyright (c) 2020 by Fraunhofer Institute for Energy Economics |
|
2 | + | # and Energy System Technology (IEE), Kassel. All rights reserved. |
|
3 | + | # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
|
4 | + | ||
5 | + | import numpy as np |
|
6 | + | from numpy import dtype |
|
7 | + | from pandapipes.constants import R_UNIVERSAL |
|
8 | + | ||
9 | + | from pandapipes.component_models.abstract_models import BranchWZeroLengthComponent, get_fluid, \ |
|
10 | + | TINIT_NODE |
|
11 | + | from pandapipes.idx_branch import D, AREA, PL, TL, \ |
|
12 | + | JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DV, BRANCH_TYPE, FROM_NODE, TO_NODE, VINIT, \ |
|
13 | + | LOAD_VEC_NODES, ELEMENT_IDX, LOSS_COEFFICIENT as LC |
|
14 | + | from pandapipes.idx_node import PINIT, NODE_TYPE, PC |
|
15 | + | from pandapipes.internals_toolbox import _sum_by_group |
|
16 | + | from pandapipes.pipeflow_setup import get_lookup, get_net_option |
|
17 | + | ||
18 | + | ||
19 | + | class PressureControlComponent(BranchWZeroLengthComponent): |
|
20 | + | """ |
|
21 | + | ||
22 | + | """ |
|
23 | + | ||
24 | + | @classmethod |
|
25 | + | def table_name(cls): |
|
26 | + | return "press_control" |
|
27 | + | ||
28 | + | @classmethod |
|
29 | + | def active_identifier(cls): |
|
30 | + | return "in_service" |
|
31 | + | ||
32 | + | @classmethod |
|
33 | + | def from_to_node_cols(cls): |
|
34 | + | return "from_junction", "to_junction" |
|
35 | + | ||
36 | + | @classmethod |
|
37 | + | def create_pit_node_entries(cls, net, node_pit, node_name): |
|
38 | + | pcs = net[cls.table_name()] |
|
39 | + | controlled = pcs.in_service & pcs.control_active |
|
40 | + | juncts = pcs['controlled_junction'].values[controlled] |
|
41 | + | press = pcs['controlled_p_bar'].values[controlled] |
|
42 | + | junction_idx_lookups = get_lookup(net, "node", "index")[node_name] |
|
43 | + | index_pc = junction_idx_lookups[juncts] |
|
44 | + | node_pit[index_pc, NODE_TYPE] = PC |
|
45 | + | node_pit[index_pc, PINIT] = press |
|
46 | + | ||
47 | + | @classmethod |
|
48 | + | def create_pit_branch_entries(cls, net, pc_pit, node_name): |
|
49 | + | """ |
|
50 | + | Function which creates pit branch entries with a specific table. |
|
51 | + | :param net: The pandapipes network |
|
52 | + | :type net: pandapipesNet |
|
53 | + | :param pc_pit: |
|
54 | + | :type pc_pit: |
|
55 | + | :param node_name: |
|
56 | + | :type node_name: |
|
57 | + | :return: No Output. |
|
58 | + | """ |
|
59 | + | pc_pit = super().create_pit_branch_entries(net, pc_pit, node_name) |
|
60 | + | pc_pit[:, D] = 0.1 |
|
61 | + | pc_pit[:, AREA] = pc_pit[:, D] ** 2 * np.pi / 4 |
|
62 | + | pc_pit[net[cls.table_name()].control_active.values, BRANCH_TYPE] = PC |
|
63 | + | pc_pit[:, LC] = net[cls.table_name()].loss_coefficient.values |
|
64 | + | ||
65 | + | @classmethod |
|
66 | + | def calculate_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options): |
|
67 | + | press_pit = super().calculate_derivatives_hydraulic(net, branch_pit, node_pit, idx_lookups, |
|
68 | + | options) |
|
69 | + | pc_branch = press_pit[:, BRANCH_TYPE] == PC |
|
70 | + | press_pit[pc_branch, JAC_DERIV_DP] = 0 |
|
71 | + | press_pit[pc_branch, JAC_DERIV_DP1] = 0 |
|
72 | + | press_pit[pc_branch, JAC_DERIV_DV] = 0 |
|
73 | + | ||
74 | + | @classmethod |
|
75 | + | def calculate_pressure_lift(cls, net, pc_pit, node_pit): |
|
76 | + | """ |
|
77 | + | ||
78 | + | :param net: The pandapipes network |
|
79 | + | :type net: pandapipesNet |
|
80 | + | :param pc_pit: |
|
81 | + | :type pc_pit: |
|
82 | + | :param node_pit: |
|
83 | + | :type node_pit: |
|
84 | + | :return: power stroke |
|
85 | + | :rtype: float |
|
86 | + | """ |
|
87 | + | pc_pit[:, PL] = 0 |
|
88 | + | ||
89 | + | @classmethod |
|
90 | + | def calculate_temperature_lift(cls, net, pc_pit, node_pit): |
|
91 | + | """ |
|
92 | + | ||
93 | + | :param net: |
|
94 | + | :type net: |
|
95 | + | :param pc_pit: |
|
96 | + | :type pc_pit: |
|
97 | + | :param node_pit: |
|
98 | + | :type node_pit: |
|
99 | + | :return: |
|
100 | + | :rtype: |
|
101 | + | """ |
|
102 | + | pc_pit[:, TL] = 0 |
|
103 | + | ||
104 | + | @classmethod |
|
105 | + | def extract_results(cls, net, options, node_name): |
|
106 | + | """ |
|
107 | + | Function that extracts certain results. |
|
108 | + | ||
109 | + | :param net: The pandapipes network |
|
110 | + | :type net: pandapipesNet |
|
111 | + | :param options: |
|
112 | + | :type options: |
|
113 | + | :param node_name: |
|
114 | + | :type node_name: |
|
115 | + | :return: No Output. |
|
116 | + | """ |
|
117 | + | ||
118 | + | placement_table, res_table, pc_pit, node_pit = super().extract_results(net, options, node_name) |
|
119 | + | ||
120 | + | node_active_idx_lookup = get_lookup(net, "node", "index_active")[node_name] |
|
121 | + | junction_idx_lookup = get_lookup(net, "node", "index")[node_name] |
|
122 | + | from_junction_nodes = node_active_idx_lookup[junction_idx_lookup[ |
|
123 | + | net[cls.table_name()]["from_junction"].values[placement_table]]] |
|
124 | + | to_junction_nodes = node_active_idx_lookup[junction_idx_lookup[ |
|
125 | + | net[cls.table_name()]["to_junction"].values[placement_table]]] |
|
126 | + | ||
127 | + | p_to = node_pit[to_junction_nodes, PINIT] |
|
128 | + | p_from = node_pit[from_junction_nodes, PINIT] |
|
129 | + | res_table['deltap_bar'].values[placement_table] = p_to - p_from |
|
130 | + | ||
131 | + | return placement_table, res_table, pc_pit |
|
132 | + | ||
133 | + | @classmethod |
|
134 | + | def get_component_input(cls): |
|
135 | + | """ |
|
136 | + | ||
137 | + | Get component input. |
|
138 | + | ||
139 | + | :return: |
|
140 | + | :rtype: |
|
141 | + | """ |
|
142 | + | return [("name", dtype(object)), |
|
143 | + | ("from_junction", "u4"), |
|
144 | + | ("to_junction", "u4"), |
|
145 | + | ("controlled_junction", "u4"), |
|
146 | + | ("controlled_p_bar", "f8"), |
|
147 | + | ("control_active", "bool"), |
|
148 | + | ("loss_coefficient", "f8"), |
|
149 | + | ("in_service", 'bool'), |
|
150 | + | ("type", dtype(object))] |
|
151 | + | ||
152 | + | @classmethod |
|
153 | + | def get_result_table(cls, net): |
|
154 | + | """ |
|
155 | + | ||
156 | + | Gets the result table. |
|
157 | + | ||
158 | + | :param net: The pandapipes network |
|
159 | + | :type net: pandapipesNet |
|
160 | + | :return: (columns, all_float) - the column names and whether they are all float type. Only |
|
161 | + | if False, returns columns as tuples also specifying the dtypes |
|
162 | + | :rtype: (list, bool) |
|
163 | + | """ |
|
164 | + | if get_fluid(net).is_gas: |
|
165 | + | output = ["v_from_m_per_s", "v_to_m_per_s", "v_mean_m_per_s", "p_from_bar", "p_to_bar", |
|
166 | + | "t_from_k", "t_to_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", |
|
167 | + | "vdot_norm_m3_per_s", "reynolds", "lambda", "normfactor_from", |
|
168 | + | "normfactor_to"] |
|
169 | + | else: |
|
170 | + | output = ["v_mean_m_per_s", "p_from_bar", "p_to_bar", "t_from_k", "t_to_k", |
|
171 | + | "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s", "reynolds", |
|
172 | + | "lambda"] |
|
173 | + | output += ["deltap_bar"] |
|
174 | + | return output, True |
Learn more Showing 5 files with coverage changes found.
pandapipes/component_models/compressor_component.py
pandapipes/component_models/pressure_control_component.py
pandapipes/properties/fluids.py
pandapipes/topology/create_graph.py
pandapipes/component_models/heat_exchanger_component.py
Files | Coverage |
---|---|
pandapipes | 0.45% 91.41% |
setup.py | 0.00% |
Project Totals (76 files) | 91.09% |
06d7494
8d3ebd3
4c06d3b
05912bd
67734d7
470fe62
1ad79b3
b2b9147
d0ec416
c23e593
2be43aa
4c0e9a9
6e43c6e
0b3c611
0e1130f
0196cad
bd7a58b
6088a4e
b094445
41fb707
39647b1
b3c35cb
da79e40
00bb150
cf8ee97
2a231e0
1200e1d
4629a82
1cebb9f
9f8cfbb
f5140e7
#207
8bc8a82
0b8366d
67f5888
77bf123
31f298c
f88f102
8f0b25e
ccfa6a3
a8faf83
2a53f60
baf8050
74d48df
b6f5f31
2842806
bdc3b3e
2508125
a1bac92
8032e51
0f238df
e0184af
563ae56
4714270
3b7b5aa
3558018
de5ee9e
6eaef12
d4ef6f1
0540c15
1907e54
574d3a1
da3d2d8