Skip to content

Commit

Permalink
Merge pull request #28 from abhishekvraman/main
Browse files Browse the repository at this point in the history
Propylean 0.2.5 release
  • Loading branch information
abhishekvraman authored Mar 18, 2023
2 parents edad7eb + 34c464a commit ca50add
Show file tree
Hide file tree
Showing 26 changed files with 736 additions and 530 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
git clone https://github.com/abhishekvraman/Propylean.git
cd Propylean
python -m build
python -m pip install dist/propylean-0.2.4-py3-none-any.whl
python -m pip install dist/propylean-0.2.5-py3-none-any.whl
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2022, 2021 Abhishek V Raman
Copyright (c) 2023, 2022, 2021 Abhishek Venkitta Raman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = propylean
version = 0.2.4
version = 0.2.5
author = Abhishek V Raman
author_email =
description = The open-source calculations and analytics package for chemical process industries.
Expand Down
2 changes: 1 addition & 1 deletion src/propylean/instruments/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def Cv(self):
Psat = self._connected_stream_property_getter(is_inlet, "material", "Psat")
Pc = self._connected_stream_property_getter(is_inlet, "material", "Pc")
if phase == 'l':
return cv_calculations.size_control_valve_l(density.value, Psat, Pc, d_viscosity.value,
return cv_calculations.size_control_valve_l(density.value, Psat.value, Pc.value, d_viscosity.value,
P1.value, P2.value,
self.inlet_mass_flowrate.value/density.value)
elif phase == 'g' or phase == 'l/g':
Expand Down
42 changes: 27 additions & 15 deletions src/propylean/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,33 @@ def __eq__(self, other):
return True
return False

class Efficiency(_Property):
def __init__(self, value=1, time_series=None, min_val=1, max_val=1):
class Dimensionless(_Property):
def __init__(self, value=None, name=None, time_series=None, min_val=None, max_val=None):
super().__init__(value=value, unit=None, time_series=time_series, max_val=max_val, min_val=min_val)
if value <= 0 or min_val <= 0 or max_val <= 0:
raise Exception("Provide a positive value for efficiency.")
self._name = name

@property
def name(self):
return self._name if self._name is not None else str(self.__class__.__name__)
@name.setter
def name(self, value):
self._name = value

@property
def unit(self):
return None
@unit.setter
def unit(self, unit):
raise Exception("{} does not have unit.".format(self.name))

def __repr__(self) -> str:
return "{} with value {}".format(self.name, self.value)

class Efficiency(Dimensionless):
def __init__(self, value=1, time_series=None, min_val=0, max_val=1):
super().__init__(value=value, name="Efficiency", time_series=time_series, max_val=max_val, min_val=min_val)
if value < 0 or min_val < 0 or max_val < 0:
raise Exception("Provide a non-negative value for efficiency.")
else:
if value > 1:
self.value = value/100
Expand All @@ -561,14 +583,4 @@ def __init__(self, value=1, time_series=None, min_val=1, max_val=1):
warn("Efficiency max_val set to {} considering value provided in percent.".format(max_val/100))
if min_val > 1:
self.min_val = min_val/100
warn("Efficiency min_val set to {} considering value provided in percent.".format(min_val/100))

def __repr__(self) -> str:
return str(self.value * 100) + "%"

@property
def unit(self):
return None
@unit.setter
def unit(self, unit):
raise Exception("Efficiency is dimensionless.")
warn("Efficiency min_val set to {} considering value provided in percent.".format(min_val/100))
Loading

0 comments on commit ca50add

Please sign in to comment.