Skip to content

cable

Cable

Cable(conductor: CableConductorProperties, layer_properties: dict[CableLayer, CableLayerProperties], layer_metrics: CableLayerMetrics, cable_type: CableType, grid_counts: dict[CableLayer, int])

Bases: AbstractCable

Finite difference cable model that discretizes cable layers into a radial grid.

Parameters:

Name Type Description Default
conductor CableConductorProperties

Conductor properties of the cable.

required
layer_properties dict[CableLayer, CableLayerProperties]

Mapping of cable layers to their properties.

required
layer_metrics CableLayerMetrics

Geometric and calculated metrics for the cable layers.

required
cable_type CableType

The type of the cable.

required
grid_counts dict[CableLayer, int]

Number of grid points per cable layer.

required
Source code in cable_thermal_model/model/cables/cable.py
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
def __init__(
    self,
    conductor: CableConductorProperties,
    layer_properties: dict[CableLayer, CableLayerProperties],
    layer_metrics: CableLayerMetrics,
    cable_type: CableType,
    grid_counts: dict[CableLayer, int],
) -> None:
    """Initialize the Cable with conductor properties, layer data, and grid resolution.

    Args:
        conductor (CableConductorProperties): Conductor properties of the cable.
        layer_properties (dict[CableLayer, CableLayerProperties]): Mapping of cable layers to their properties.
        layer_metrics (CableLayerMetrics): Geometric and calculated metrics for the cable layers.
        cable_type (CableType): The type of the cable.
        grid_counts (dict[CableLayer, int]): Number of grid points per cable layer.

    """
    super().__init__(conductor, layer_properties, layer_metrics, cable_type)

    self._validate_grid_counts(grid_counts)

    self._grid_counts = grid_counts
    self._radii_grid = np.array([], dtype=float)
    self._inter_radii_grid = np.array([], dtype=float)
    self._surface_area_grid = np.array([], dtype=float)
    self._capacity_grid = np.array([], dtype=float)
    self._rho_grid = np.array([], dtype=float)

    self._upper_diagonal = np.array([], dtype=float)
    self._base_diagonal = np.array([], dtype=float)
    self._lower_diagonal = np.array([], dtype=float)
    self._finite_difference_matrix_diagonals_outdated = True

    self._heating_vector = np.array([], dtype=float)

    self._set_calculated_fields()

info property

info: str

Return a compact string encoding the cable's physical properties.

grid_size property

grid_size: int

Get the total number of grid points in the finite difference model.

Returns:

Name Type Description
int int

The total number of grid points.

update_pipe_fill_resistivity

update_pipe_fill_resistivity(temperature_grid: ndarray) -> None

This method updates the (temperature dependent) thermal resistivity of the medium in the pipe of the cable.

Parameters:

Name Type Description Default
temperature_grid ndarray

The temperature grid for the cable, as calculated for a given timestep.

required
Source code in cable_thermal_model/model/cables/cable.py
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
def update_pipe_fill_resistivity(self, temperature_grid: np.ndarray) -> None:
    """This method updates the (temperature dependent) thermal resistivity of the medium in the pipe of the cable.

    Args:
        temperature_grid (np.ndarray): The temperature grid for the cable, as calculated for a given timestep.

    """
    if self.layer_metrics.pipe is None:
        raise ValueError("Pipe is not set. Cannot update pipe fill resistivity.")
    if self.layer_metrics.pipe.inner_radius is None:
        raise ValueError("Pipe inner radius is not set. Cannot update pipe fill resistivity.")

    Tfill = self._get_mean_temperature_cable_layer(temperature_grid=temperature_grid, layer=CableLayer.PipeFill)

    new_pipe_fill_rho = self.layer_metrics.pipe.get_thermal_resistivity_pipe_fill(Tfill)
    pipe_fill_start_index, pipe_fill_end_index = self.get_layer_indices_for_layer(CableLayer.PipeFill)
    self._update_rho_grid(
        start_index=pipe_fill_start_index,
        end_index=pipe_fill_end_index,
        rho_values=new_pipe_fill_rho,
    )

get_layer_indices_for_layer

get_layer_indices_for_layer(layer: CableLayer) -> tuple[int, int]

This method fetches the inclusive start and end indices of the grid points for a given layer.

Parameters:

Name Type Description Default
layer CableLayer

A CableLayer object representing the layer for which the indices need to be fetched.

required

Returns:

Type Description
tuple[int, int]

tuple[int, int]: A tuple of integers representing the inclusive start and end indices of the grid points for the given layer, in that order.

Source code in cable_thermal_model/model/cables/cable.py
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
def get_layer_indices_for_layer(self, layer: CableLayer) -> tuple[int, int]:
    """This method fetches the inclusive start and end indices of the grid points for a given layer.

    Args:
        layer (CableLayer): A CableLayer object representing the layer for
            which the indices need to be fetched.

    Returns:
        tuple[int, int]: A tuple of integers representing the inclusive start and end
            indices of the grid points for the given layer, in that order.

    """
    layer_index = self.layers.index(layer)

    layer_start_index = sum([self._grid_counts[layer] for layer in self.layers[:layer_index]])
    layer_end_index = layer_start_index + self._grid_counts[layer] - 1
    return layer_start_index, layer_end_index

get_heating_contribution_at_radius

get_heating_contribution_at_radius(radius: float, self_heating_contribution: ndarray) -> float

Interpolate the self-heating contribution at a given radius.

Parameters:

Name Type Description Default
radius float

Radial distance at which to evaluate the self-heating contribution.

required
self_heating_contribution ndarray

Self-heating contribution state values for the cable.

required

Returns:

Name Type Description
float float

Interpolated temperature-rise contribution due to cable self-heating at the requested radius.

Source code in cable_thermal_model/model/cables/cable.py
505
506
507
508
509
510
511
512
513
514
515
516
def get_heating_contribution_at_radius(self, radius: float, self_heating_contribution: np.ndarray) -> float:
    """Interpolate the self-heating contribution at a given radius.

    Args:
        radius (float): Radial distance at which to evaluate the self-heating contribution.
        self_heating_contribution (np.ndarray): Self-heating contribution state values for the cable.

    Returns:
        float: Interpolated temperature-rise contribution due to cable self-heating at the requested radius.

    """
    return float(np.interp(x=[radius], xp=self._radii_grid, fp=self_heating_contribution)[0])

get_cable_copy_with_pipe

get_cable_copy_with_pipe(pipe: Pipe) -> Self

Get a new cable instance based on the current self, but with extra added layers that model a pipe.

This method adds two layers
  1. pipe_fill layer with an empiric resistance value
  2. PE layer for the pipe

The resistivity of the pipe filling material is updated depending on the temperature.

Parameters:

Name Type Description Default
pipe Pipe

A pipe instance

required

Returns:

Type Description
Cable

A new Cable instance based on the Cable instance the method was called from, but with the added pipe layers, as if the cable had an outer pipe added.

Source code in cable_thermal_model/model/cables/cable.py
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
def get_cable_copy_with_pipe(self, pipe: Pipe) -> Self:
    """Get a new cable instance based on the current self, but with extra added layers that model a pipe.

    This method adds two layers:
     1. pipe_fill layer with an empiric resistance value
     2. PE layer for the pipe
    The resistivity of the pipe filling material is updated depending on the temperature.

    Args:
        pipe (Pipe): A pipe instance

    Returns:
        (Cable): A new Cable instance based on the Cable instance the method was called from, but with
                    the added pipe layers, as if the cable had an outer pipe added.

    """
    # Check whether there is already a soil layer present around the cable
    if self.layer_properties[self.layers[-1]].outer_radius != self.layer_metrics.outer_radius:
        raise ValueError(
            "Detected soil layers. "
            "The add_outer_pipe method is only intended for cable instances without soil layers."
        )

    if self.layer_metrics.pipe is not None:
        raise ValueError("Cannot add a pipe as the cable already has a pipe.")

    new_cable = deepcopy(self)

    # Create a new cable, using the get_redefined_cable() method, with the new values where the cable should be
    # altered to accommodate the pipe.
    grid_counts = new_cable._grid_counts
    layer_properties: list[tuple[CableLayer, float, float, float]] = [
        (CableLayer.PipeFill, pipe.inner_radius, pipe.get_thermal_resistivity_pipe_fill(), pipe.pipe_fill_cap),
        (CableLayer.Pipe, pipe.outer_radius, 3.5, 2.4e6),
    ]

    for layer, layer_outer_radius, rho, capacity in layer_properties:
        new_cable.layer_properties[layer] = CableLayerProperties(
            layer=layer,
            inner_radius=new_cable.layer_properties[new_cable.layers[-1]].outer_radius,
            outer_radius=layer_outer_radius,
            rho=rho,
            capacity=capacity,
        )
        new_cable.layers.append(layer)
        grid_counts[layer] = 10  # Default grid count for pipe layers

    new_cable.layer_metrics.pipe = pipe
    new_cable.layer_metrics.outer_radius = pipe.outer_radius

    return new_cable._get_redefined_cable(
        layer_properties=new_cable.layer_properties,
        layer_metrics=new_cable.layer_metrics,
        grid_counts=grid_counts,
    )

add_dielectric_loss_to_heating_vector

add_dielectric_loss_to_heating_vector() -> None

This method calculates and updates the heating vector with dielectric loss.

Source code in cable_thermal_model/model/cables/cable.py
574
575
576
577
578
579
580
def add_dielectric_loss_to_heating_vector(self) -> None:
    """This method calculates and updates the heating vector with dielectric loss."""
    dielectric_loss = self.get_dielectric_loss_for_cable()
    self._update_vector_with_heat_generation_for_layer(
        heat_generation=dielectric_loss,
        layer=CableLayer.Insulation,
    )