Skip to content

Commit

Permalink
added docs for distribution bus and distribution load (#37)
Browse files Browse the repository at this point in the history
* added docs for distribution bus and distribution load
* added examples for distribution transformer
* first stable release
* upgraded actions_python_ruff from 1.0.0 to 1.0.1
* added check src in ruff lint
  • Loading branch information
KapilDuwadi authored Aug 5, 2024
1 parent 428b51e commit d364b89
Show file tree
Hide file tree
Showing 16 changed files with 1,017 additions and 48 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/pull_request_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
- name: Run pytest
run: |
pytest -v --cov --cov-report=xml
cd docs
pytest --doctest-glob="*.md"
cd ..
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
Expand All @@ -33,8 +36,8 @@ jobs:
runs-on: ubuntu-latest
name: "ruff"
steps:
- uses: davidslusser/actions_python_ruff@v1.0.0
- uses: davidslusser/actions_python_ruff@v1.0.1
with:
src: "src"
src: "check src"
pip_install_command: "pip install -e .[dev]"
python_version: "3.11"
8 changes: 0 additions & 8 deletions docs/api/distribution_component.md

This file was deleted.

9 changes: 0 additions & 9 deletions docs/api/equipment/distribution_transformer_equipment.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@
:exclude-members: example, validate_fields
```


```{eval-rst}
.. autopydantic_model:: gdm.TapWindingEquipment
:members: __init__
:inherited-members: Component
:exclude-members: example, validate_fields
```


```{eval-rst}
.. autopydantic_model:: gdm.DistributionTransformerEquipment
:members: __init__
Expand Down
8 changes: 8 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,11 @@ api/index
cim/index
```


```{toctree}
:caption: Usage
:hidden: true
usage/index
```
9 changes: 9 additions & 0 deletions docs/usage/components/distribution_branch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Distributio Branch

_under development_

## Matrix Impedance Branch

## Geometry Branch

## Sequence Impedance Branch
91 changes: 91 additions & 0 deletions docs/usage/components/distribution_bus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Distribution Bus

Single phase bus.

```python
>>> from gdm import (
... DistributionBus,
... PositiveVoltage,
... VoltageTypes,
... Phase
... )
>>> DistributionBus(
... name="Bus-1",
... nominal_voltage=PositiveVoltage(7.62, "kilovolts"),
... voltage_type=VoltageTypes.LINE_TO_GROUND,
... phases=[Phase.A]
... )
DistributionBus(name='Bus-1',
substation=None,
feeder=None,
voltage_type=<VoltageTypes.LINE_TO_GROUND: 'line-to-ground'>,
phases=[<Phase.A: 'A'>],
voltagelimits=[],
nominal_voltage=<Quantity(7.62, 'kilovolt')>,
coordinate=None)

```

Three phase bus.

```python
>>> DistributionBus(
... name="Bus-1",
... nominal_voltage=PositiveVoltage(7.62, "kilovolts"),
... voltage_type=VoltageTypes.LINE_TO_GROUND,
... phases=[Phase.A, Phase.B, Phase.C]
... )
DistributionBus(name='Bus-1',
substation=None,
feeder=None,
voltage_type=<VoltageTypes.LINE_TO_GROUND: 'line-to-ground'>,
phases=[<Phase.A: 'A'>, <Phase.B: 'B'>, <Phase.C: 'C'>],
voltagelimits=[],
nominal_voltage=<Quantity(7.62, 'kilovolt')>,
coordinate=None)

```

A bus with cartesian coordinates.

```python
>>> from gdm import Location
>>> DistributionBus(
... name="Bus-1",
... nominal_voltage=PositiveVoltage(7.62, "kilovolts"),
... voltage_type=VoltageTypes.LINE_TO_GROUND,
... phases=[Phase.A, Phase.B, Phase.C],
... coordinate=Location(x=10.0, y=20.0)
... )
DistributionBus(name='Bus-1',
substation=None,
feeder=None,
voltage_type=<VoltageTypes.LINE_TO_GROUND: 'line-to-ground'>,
phases=[<Phase.A: 'A'>, <Phase.B: 'B'>, <Phase.C: 'C'>],
voltagelimits=[],
nominal_voltage=<Quantity(7.62, 'kilovolt')>,
coordinate=Location(name='', x=10.0, y=20.0, crs=None))

```

A bus with coordinate reference system.

```python
>>> from gdm import Location
>>> DistributionBus(
... name="Bus-1",
... nominal_voltage=PositiveVoltage(7.62, "kilovolts"),
... voltage_type=VoltageTypes.LINE_TO_GROUND,
... phases=[Phase.A, Phase.B, Phase.C],
... coordinate=Location(x=10.0, y=20.0, crs='epsg:4326')
... )
DistributionBus(name='Bus-1',
substation=None,
feeder=None,
voltage_type=<VoltageTypes.LINE_TO_GROUND: 'line-to-ground'>,
phases=[<Phase.A: 'A'>, <Phase.B: 'B'>, <Phase.C: 'C'>],
voltagelimits=[],
nominal_voltage=<Quantity(7.62, 'kilovolt')>,
coordinate=Location(name='', x=10.0, y=20.0, crs='epsg:4326'))

```
213 changes: 213 additions & 0 deletions docs/usage/components/distribution_load.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# Distribution Load

## Single Phase Constant Power Load

Creating a single-phase constant power load connected to a bus. A constant power load means that the power (both real and reactive) remains constant irrespective of voltage variations. The parameters p_real and p_imag are set to 1.0, indicating that the load is a constant power type.

```python
>>> from gdm import (
... DistributionBus,
... DistributionLoad,
... LoadEquipment,
... PositiveVoltage,
... VoltageTypes,
... PhaseLoadEquipment,
... Phase,
... ActivePower,
... ReactivePower
... )
>>> bus1 = DistributionBus(
... name="Bus-1",
... nominal_voltage=PositiveVoltage(7.62, "kilovolts"),
... voltage_type=VoltageTypes.LINE_TO_GROUND,
... phases=[Phase.A]
... )
>>> phase_load_equipment = PhaseLoadEquipment(
... name="Phase-Load-1",
... real_power=ActivePower(3.5, "kilowatt"),
... reactive_power=ReactivePower(0, "kilovar"),
... z_real=0,
... z_imag=0,
... i_real=0,
... i_imag=0,
... p_real=1.0,
... p_imag=1.0
... )
>>> load_equipment = LoadEquipment(
... name="LoadEquipment-1",
... phase_loads=[phase_load_equipment]
... )
>>> DistributionLoad(
... name="Load-1",
... bus=bus1,
... phases=[Phase.A],
... equipment=load_equipment
... ).pprint()
DistributionLoad(
name='Load-1',
substation=None,
feeder=None,
bus=DistributionBus(
name='Bus-1',
substation=None,
feeder=None,
voltage_type=<VoltageTypes.LINE_TO_GROUND: 'line-to-ground'>,
phases=[<Phase.A: 'A'>],
voltagelimits=[],
nominal_voltage=<Quantity(7.62, 'kilovolt')>,
coordinate=None
),
phases=[<Phase.A: 'A'>],
equipment=LoadEquipment(
name='LoadEquipment-1',
phase_loads=[
PhaseLoadEquipment(
name='Phase-Load-1',
real_power=<Quantity(3.5, 'kilowatt')>,
reactive_power=<Quantity(0, 'kilovar')>,
z_real=0.0,
z_imag=0.0,
i_real=0.0,
i_imag=0.0,
p_real=1.0,
p_imag=1.0,
num_customers=None
)
],
connection_type=<ConnectionType.STAR: 'STAR'>
)
)

```

## Three Phase Delta Connected Constant Power Load


For the three-phase delta-connected constant power load, we need to define the load for all three phases (A, B, and C) and set the connection type to delta. In a delta connection, the load is connected between phases rather than from phase to neutral (as in a star connection).



```python
>>> from gdm import (
... DistributionBus,
... DistributionLoad,
... LoadEquipment,
... PositiveVoltage,
... VoltageTypes,
... PhaseLoadEquipment,
... Phase,
... ActivePower,
... ReactivePower,
... ConnectionType
... )
>>> bus2 = DistributionBus(
... name="Bus-2",
... nominal_voltage=PositiveVoltage(13.8, "kilovolts"),
... voltage_type=VoltageTypes.LINE_TO_LINE,
... phases=[Phase.A, Phase.B, Phase.C]
... )
>>> phase_load_equipment_a = PhaseLoadEquipment(
... name="Phase-Load-A",
... real_power=ActivePower(5.0, "kilowatt"),
... reactive_power=ReactivePower(2.0, "kilovar"),
... z_real=0,
... z_imag=0,
... i_real=0,
... i_imag=0,
... p_real=1.0,
... p_imag=1.0
... )
>>> phase_load_equipment_b = PhaseLoadEquipment(
... name="Phase-Load-B",
... real_power=ActivePower(5.0, "kilowatt"),
... reactive_power=ReactivePower(2.0, "kilovar"),
... z_real=0,
... z_imag=0,
... i_real=0,
... i_imag=0,
... p_real=1.0,
... p_imag=1.0
... )
>>> phase_load_equipment_c = PhaseLoadEquipment(
... name="Phase-Load-C",
... real_power=ActivePower(5.0, "kilowatt"),
... reactive_power=ReactivePower(2.0, "kilovar"),
... z_real=0,
... z_imag=0,
... i_real=0,
... i_imag=0,
... p_real=1.0,
... p_imag=1.0
... )
>>> load_equipment_delta = LoadEquipment(
... name="LoadEquipment-Delta",
... phase_loads=[phase_load_equipment_a, phase_load_equipment_b, phase_load_equipment_c],
... connection_type=ConnectionType.DELTA
... )
>>> distribution_load_delta = DistributionLoad(
... name="Load-Delta",
... bus=bus2,
... phases=[Phase.A, Phase.B, Phase.C],
... equipment=load_equipment_delta
... )
>>> distribution_load_delta.pprint()
DistributionLoad(
name='Load-Delta',
substation=None,
feeder=None,
bus=DistributionBus(
name='Bus-2',
substation=None,
feeder=None,
voltage_type=<VoltageTypes.LINE_TO_LINE: 'line-to-line'>,
phases=[<Phase.A: 'A'>, <Phase.B: 'B'>, <Phase.C: 'C'>],
voltagelimits=[],
nominal_voltage=<Quantity(13.8, 'kilovolt')>,
coordinate=None
),
phases=[<Phase.A: 'A'>, <Phase.B: 'B'>, <Phase.C: 'C'>],
equipment=LoadEquipment(
name='LoadEquipment-Delta',
phase_loads=[
PhaseLoadEquipment(
name='Phase-Load-A',
real_power=<Quantity(5.0, 'kilowatt')>,
reactive_power=<Quantity(2.0, 'kilovar')>,
z_real=0.0,
z_imag=0.0,
i_real=0.0,
i_imag=0.0,
p_real=1.0,
p_imag=1.0,
num_customers=None
),
PhaseLoadEquipment(
name='Phase-Load-B',
real_power=<Quantity(5.0, 'kilowatt')>,
reactive_power=<Quantity(2.0, 'kilovar')>,
z_real=0.0,
z_imag=0.0,
i_real=0.0,
i_imag=0.0,
p_real=1.0,
p_imag=1.0,
num_customers=None
),
PhaseLoadEquipment(
name='Phase-Load-C',
real_power=<Quantity(5.0, 'kilowatt')>,
reactive_power=<Quantity(2.0, 'kilovar')>,
z_real=0.0,
z_imag=0.0,
i_real=0.0,
i_imag=0.0,
p_real=1.0,
p_imag=1.0,
num_customers=None
)
],
connection_type=<ConnectionType.DELTA: 'DELTA'>
)
)

```
Loading

0 comments on commit d364b89

Please sign in to comment.