<commit_before>import numpy as np
import CoolProp as CP
from copy import copy
from scipy.optimize import newton
from prf.state import *


__all__ = ['Point', 'n_exp', 'head_pol', 'eff_pol', 'head_isen',
           'eff_isen', 'schultz_f', 'head_pol_schultz', 'eff_pol_schultz',
           'convert_to_base_units']


class Point:
    @convert_to_base_units
    def __init__(self, *args, **kwargs):
        """Point.

        A point in the compressor map that can be defined in different ways.

        Parameters
        ----------
        suc, disch : prf.State, prf.State
            Suction and discharge states for the point.

        suc, head, eff : prf.State, float, float
            Suction state, polytropic head and polytropic efficiency.

        suc, head, power : prf.State, float, float
            Suction state, polytropic head and gas power.

        suc, eff, vol_ratio : prf.State, float, float
            Suction state, polytropic efficiecy and volume ratio.

        Returns
        -------
        Point : prf.Point
            A point in the compressor map.


        """
        # TODO create dictionary with optional inputs
        self.suc = kwargs.get('suc')

        try:
            self.speed = kwargs['speed']
            if 'flow_m' not in kwargs:
                self.flow_v = kwargs['flow_v']
                self.flow_m = self.flow_v * self.suc.rhomass()
            else:
                self.flow_m = kwargs['flow_m']
                self.flow_v = self.flow_m / self.suc.rhomass()
        except KeyError as err:
            raise Exception('Argument not provided', err.args[0]) from err

        self.disch = kwargs.get('disch')
        self.head = kwargs.get('head')
        self.eff = kwargs.get('eff')
        self.power = kwargs.get('power')
        self.volume_ratio = kwargs.get('volume_ratio')

        if self.suc and self.disch is not None:
            self.calc_from_suc_disch(self.suc, self.disch)
        elif self.suc and self.head and self.eff is not None:
            self.calc_from_suc_head_eff(self.suc, self.head, self.eff)
        elif self.suc and self.head and self.power is not None:
            self.calc_from_suc_head_power(self.suc, self.head, self.power)
        elif self.suc and self.eff and self.volume_ratio is not None:
            self.calc_from_suc_eff_vol_ratio(self.suc, self.eff, self.volume_ratio)
        else:
            raise KeyError('Argument not provided')

        if self.volume_ratio is None:
            self.volume_ratio = self.suc.rhomass() / self.disch.rhomass()

        self.mach_comparison = kwargs.get('mach_comparison')
        self.reynolds_comparison = kwargs.get('reynolds_comparison')
        self.volume_ratio_comparison = kwargs.get('volume_ratio_comparison')

    def __repr__(self):
        return (
            '\nPoint: '
            + '\n Volume flow: {:10.5} m^3 / s'.format(self.flow_v)
            + '\n Head       : {:10.5} J / kg.K'.format(self.head)
            + '\n Efficiency : {:10.5} %'.format(100 * self.eff)
        )

    # TODO Put pol. head/eff and isen. head/eff functions inside point class

    def calc_from_suc_disch(self, suc, disch):
        self.head = head_pol_schultz(suc, disch)
        self.eff = eff_pol_schultz(suc, disch)
        self.power = power(self.flow_m, self.head, self.eff)<commit_msg>Added power to point repr.<commit_after>import numpy as np
import CoolProp as CP
from copy import copy
from scipy.optimize import newton
from prf.state import *


__all__ = ['Point', 'n_exp', 'head_pol', 'eff_pol', 'head_isen',
           'eff_isen', 'schultz_f', 'head_pol_schultz', 'eff_pol_schultz',
           'convert_to_base_units']


class Point:
    @convert_to_base_units
    def __init__(self, *args, **kwargs):
        """Point.

        A point in the compressor map that can be defined in different ways.

        Parameters
        ----------
        speed : float
            Speed in 1/s.

        flow_v or flow_m : float
            Volumetric or mass flow.

        suc, disch : prf.State, prf.State
            Suction and discharge states for the point.

        suc, head, eff : prf.State, float, float
            Suction state, polytropic head and polytropic efficiency.

        suc, head, power : prf.State, float, float
            Suction state, polytropic head and gas power.

        suc, eff, vol_ratio : prf.State, float, float
            Suction state, polytropic efficiecy and volume ratio.

        Returns
        -------
        Point : prf.Point
            A point in the compressor map.


        """
        # TODO create dictionary with optional inputs
        self.suc = kwargs.get('suc')

        try:
            self.speed = kwargs['speed']
            if 'flow_m' not in kwargs:
                self.flow_v = kwargs['flow_v']
                self.flow_m = self.flow_v * self.suc.rhomass()
            else:
                self.flow_m = kwargs['flow_m']
                self.flow_v = self.flow_m / self.suc.rhomass()
        except KeyError as err:
            raise Exception('Argument not provided', err.args[0]) from err

        self.disch = kwargs.get('disch')
        self.head = kwargs.get('head')
        self.eff = kwargs.get('eff')
        self.power = kwargs.get('power')
        self.volume_ratio = kwargs.get('volume_ratio')

        if self.suc and self.disch is not None:
            self.calc_from_suc_disch(self.suc, self.disch)
        elif self.suc and self.head and self.eff is not None:
            self.calc_from_suc_head_eff(self.suc, self.head, self.eff)
        elif self.suc and self.head and self.power is not None:
            self.calc_from_suc_head_power(self.suc, self.head, self.power)
        elif self.suc and self.eff and self.volume_ratio is not None:
            self.calc_from_suc_eff_vol_ratio(self.suc, self.eff, self.volume_ratio)
        else:
            raise KeyError('Argument not provided')

        if self.volume_ratio is None:
            self.volume_ratio = self.suc.rhomass() / self.disch.rhomass()

        self.mach_comparison = kwargs.get('mach_comparison')
        self.reynolds_comparison = kwargs.get('reynolds_comparison')
        self.volume_ratio_comparison = kwargs.get('volume_ratio_comparison')

    def __repr__(self):
        return (
            '\nPoint: '
            + '\n Volume flow: {:10.5} m^3 / s'.format(self.flow_v)
            + '\n Head       : {:10.5} J / kg.K'.format(self.head)
            + '\n Efficiency : {:10.5} %'.format(100 * self.eff)
            + '\n Power      : {:10.5} W'.format(self.power)
        )

    # TODO Put pol. head/eff and isen. head/eff functions inside point class

    def calc_from_suc_disch(self, suc, disch):
        self.head = head_pol_schultz(suc, disch)
        self.eff = eff_pol_schultz(suc, disch)
        self.power = power(self.flow_m, self.head, self.eff)
{'fraction_non_alphanumeric': 0.1089238845144357, 'fraction_numerical': 0.004666083406240887, 'mean_word_length': 2.0661600357621817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2700733', 'n_tokens_mistral': 2215, 'n_tokens_neox': 2102, 'n_words': 554}