-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Describe the bug
compute_efficiency() computes:
slip = rotor_cu_loss / rotor_output
and efficiency = rotor_output * 100 / (self.power_y * self.power_scale)
If rotor_output == 0 (or self.power_y == 0), it will raise ZeroDivisionError or generate inf/NaN.
This computation is visible in the module code.
https://electricpy.readthedocs.io/en/latest/_modules/electricpy/visu.html
Reproduction Code
# Setup
import electricpy as ep
# Code which causes failure
# This is a minimal-style repro: create a circle object and force values that
# drive rotor_output to 0 (or power_y to 0). Depending on constructor behavior,
# you may need to use the class' normal initialization and then override fields.
# NOTE: If the class requires real test data to construct, you can reproduce after
# constructing normally by forcing:
# imc.power_y = 0
# or forcing rotor_output to compute to 0 by selecting values that cancel losses.
imc = ep.visu.InductionMotorCircle(
no_load_data=[(0, 0), (1, 0)], # placeholder-like but valid shape
blocked_rotor_data=[(0, 0), (1, 0)]
)
# Force a state that will trigger division by zero in compute_efficiency
imc.power_y = 0
imc.power_scale = 1
imc.power_x = 1
imc.no_load_line = [(0, 0), (1, 0)]
imc.torque_line = [(0, 0), (1, 0)]
imc.secondary_current_line = [(0, 0), (1, 0)]
imc.sync_speed = 1800
imc.compute_efficiency()Expected behavior
Either:
handle the zero cases gracefully (return None, NaN, or a clear message), or
raise a clear, intentional exception explaining invalid operating point/data.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. Linux]
- Python Version [e.g. 3.7]
- Version [e.g. 0.2.1]
Additional context
The divisions are performed without guarding against rotor_output == 0 or power_y == 0.