Source code for connector.work_connector

# -*- coding: utf-8 -*-
"""
Created on Tue Sep 10 14:09:18 2024

@author: Elise Neven
@email: elise.neven@uliege.be

"""
import warnings

[docs] class WorkConnector: """ A class to handle transfer of work power. **Attributes**: W_dot : float, optional Work power in W. N : float, optional Speed in rpm. C : float, optional Torque in Nm. variables_input : list of lists A list of the variables used to define the work connector. Each entry is a list of [variable_name, value]. **Methods**: __init__(self): Initializes the WorkConnector object with. set_W_dot(self, value): Sets the work power and updates the list of known variables. set_N(self, value): Sets the speed and updates the list of known variables. set_C(self, value): Sets the torque and updates the list of known variables. print_resume(self): Print a summary of the work connector properties. """ def __init__(self): self.variables_input = [] self.W_dot = None # Work power [W] self.w = None # Specific work [J/kg] self.N_rot = None # Speed [rpm] self.C = None # Torque [Nm] self.W_dot_el = None # Electrical power [W] def set_properties(self, **kwargs): for key, value in kwargs.items(): if key == 'W_dot': self.set_W_dot(value) elif key == 'w': self.set_w(value) elif key == 'N_rot': self.set_N_rot(value) elif key == 'C': self.set_C(value) elif key == 'W_dot_el': self.set_W_dot_el(value) else: warnings.warn(f"Error: Invalid property '{key}'") def calculate_properties(self): pass def set_W_dot(self, value): self.W_dot = value self.variables_input = self.variables_input + [['W_dot', value]] self.calculate_properties() def set_w(self, value): #Specific work [J/kg] self.w = value self.variables_input = self.variables_input + [['w', value]] self.calculate_properties() def set_N_rot(self, value): self.N_rot = value self.variables_input = self.variables_input + [['N_rot', value]] self.calculate_properties() def set_C(self, value): self.C = value self.variables_input = self.variables_input + [['C', value]] self.calculate_properties() def set_W_dot_el(self, value): self.W_dot_el = value self.variables_input = self.variables_input + [['W_dot_el', value]] self.calculate_properties() def print_resume(self): """ Print a summary of the work connector properties """ print("Work power: " + str(self.W_dot) + " [W]") print("Specific work: " + str(self.w) + " [J/kg]") print("Speed: " + str(self.N_rot) + " [rpm]") print("Torque: " + str(self.C) + " [Nm]") print("Electrical power: " + str(self.W_dot_el) + " [W]")