|
1 | 1 | from collections import defaultdict |
2 | 2 | from itertools import islice |
3 | | -from typing import Dict, Iterable, Iterator, Tuple |
| 3 | +from typing import Iterable, Iterator |
4 | 4 |
|
5 | | -from numpy import arctan, array, cos, exp, log, ndarray |
| 5 | +from numpy import arctan, array, cos, exp, log, ndarray, sin, sqrt, zeros |
6 | 6 | from numpy import pi as π |
7 | | -from numpy import sin, sqrt, zeros |
8 | 7 | from numpy.linalg import inv |
9 | 8 |
|
10 | 9 | alpha = exp(2j * π / 3) |
@@ -94,15 +93,14 @@ def calculate_sequence_impedances(Z): |
94 | 93 |
|
95 | 94 |
|
96 | 95 | class CarsonsEquations: |
97 | | - |
98 | 96 | ρ = 100 # resistivity, ohms/meter^3 |
99 | 97 | μ = 4 * π * 1e-7 # permeability, Henry / meter |
100 | 98 |
|
101 | 99 | def __init__(self, model): |
102 | 100 | self.phases: Iterable[str] = model.phases |
103 | | - self.phase_positions: Dict[str, Tuple[float, float]] = model.wire_positions |
104 | | - self.gmr: Dict[str, float] = model.geometric_mean_radius |
105 | | - self.r: Dict[str, float] = model.resistance |
| 101 | + self.phase_positions: dict[str, tuple[float, float]] = model.wire_positions |
| 102 | + self.gmr: dict[str, float] = model.geometric_mean_radius |
| 103 | + self.r: dict[str, float] = model.resistance |
106 | 104 |
|
107 | 105 | self.ƒ = getattr(model, "frequency", 60) |
108 | 106 | self.ω = 2.0 * π * self.ƒ # angular frequency radians / second |
@@ -254,15 +252,15 @@ def compute_X(self, i, j) -> float: |
254 | 252 | class ConcentricNeutralCarsonsEquations(ModifiedCarsonsEquations): |
255 | 253 | def __init__(self, model, *args, **kwargs): |
256 | 254 | super().__init__(model) |
257 | | - self.neutral_strand_gmr: Dict[str, float] = model.neutral_strand_gmr |
258 | | - self.neutral_strand_count: Dict[str, float] = defaultdict( |
| 255 | + self.neutral_strand_gmr: dict[str, float] = model.neutral_strand_gmr |
| 256 | + self.neutral_strand_count: dict[str, float] = defaultdict( |
259 | 257 | lambda: None, model.neutral_strand_count |
260 | 258 | ) |
261 | | - self.neutral_strand_resistance: Dict[ |
262 | | - str, float |
263 | | - ] = model.neutral_strand_resistance |
| 259 | + self.neutral_strand_resistance: dict[str, float] = ( |
| 260 | + model.neutral_strand_resistance |
| 261 | + ) |
264 | 262 | # fmt: off |
265 | | - self.radius: Dict[str, float] = defaultdict( |
| 263 | + self.radius: dict[str, float] = defaultdict( |
266 | 264 | lambda: None, |
267 | 265 | { |
268 | 266 | phase: (diameter_over_neutral - model.neutral_strand_diameter[phase]) / 2 |
@@ -316,7 +314,6 @@ def GMR_cn(self, phase) -> float: |
316 | 314 |
|
317 | 315 |
|
318 | 316 | class TapeShieldedCableCarsonsEquations(ModifiedCarsonsEquations): |
319 | | - |
320 | 317 | ρ_tape_shield = 1.7721e-8 # copper resistivity at 20 degrees, ohm-meter |
321 | 318 |
|
322 | 319 | def __init__(self, model, *args, **kwargs): |
@@ -373,7 +370,7 @@ def conductors(self): |
373 | 370 | class MultiConductorCarsonsEquations(ModifiedCarsonsEquations): |
374 | 371 | def __init__(self, model): |
375 | 372 | super().__init__(model) |
376 | | - self.outside_radius: Dict[str, float] = model.outside_radius |
| 373 | + self.outside_radius: dict[str, float] = model.outside_radius |
377 | 374 |
|
378 | 375 | def compute_d(self, i, j) -> float: |
379 | 376 | # Assumptions: |
|
0 commit comments