Skip to content

Commit

Permalink
Merge pull request #14 from Rigel09/feature/UI
Browse files Browse the repository at this point in the history
Creating a command line UI interface for package
  • Loading branch information
Rigel09 committed Mar 19, 2023
2 parents 5c2fccd + c5bbae8 commit ed9ebae
Show file tree
Hide file tree
Showing 18 changed files with 6,746 additions and 10 deletions.
1,866 changes: 1,866 additions & 0 deletions CompAero/Calculator/CalculatorUI.py

Large diffs are not rendered by default.

Empty file added CompAero/Calculator/__init__.py
Empty file.
575 changes: 575 additions & 0 deletions CompAero/Calculator/calculator_main.py

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions CompAero/Calculator/decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from typing import Callable

def error_message_decorator(func) -> Callable:

def _wrapped_func(self):
result = None
try:
result = func(self)
except ValueError as e:
self.show_error(f"Error Occured! \n {e}")
return result
return _wrapped_func
11 changes: 11 additions & 0 deletions CompAero/FannoFlowRelations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from math import sqrt, nan, pow, isnan, log
from scipy.optimize import brenth
from colorama import Back, Style, Fore
from enum import Enum
from CompAero.greek_letters import LowerCaseGreek as lcg
from CompAero.internal import (
FlowState,
Expand All @@ -14,6 +15,16 @@
seperator,
)

class FannoFlowChoice(Enum):
GAMMA_MACH = "gamma, mach"
GAMMA_T_T_ST = "gamma, T/T*"
GAMMA_P_P_ST = "gamma, P/P*"
GAMMA_RHO_RHO_ST = "gamma, rho/rho*"
GAMMA_PO_PO_ST = "gamma, P0/P0*"
GAMMA_4FLSTD_FLOW_TYPE = "gamma, 4FL*/D, flowtype"
GAMMA_U_U_ST = "gamma, U/U*"

FANNO_FLOW_VALID_OPTIONS = [x.value for x in FannoFlowChoice]

class FannoFlowRelations:
""" This class is a collective name space for basic calculations regarding Fanno flows.
Expand Down
17 changes: 17 additions & 0 deletions CompAero/IsentropecRelations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import enum
from CompAero.internal import (
InvalidOptionCombinationError,
checkValue,
Expand All @@ -13,6 +14,22 @@
from math import sqrt, nan, pow
from scipy.optimize import brenth

ISENTROPIC_VALID_OPTIONS = [
"gamma, mach",
" gamma, P0/P",
" gamma, T0/T",
" gamma, Rho0/Rho",
" gamma, A/A*",
]


class ISENTROPIC_CHOICE:
MACH = "gamma, mach"
P0_P = " gamma, P0/P"
T0_T = " gamma, T0/T"
RHO0_RHO = " gamma, Rho0/Rho"
A_ASTAR = " gamma, A/A*"


class IsentropicRelations:
""" This class is a collective name space for basic calculations regarding isentropic flows.
Expand Down
21 changes: 21 additions & 0 deletions CompAero/NormalShockRelations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from enum import Enum
from math import sqrt, nan, pow, isnan
from scipy.optimize import brenth

Expand All @@ -13,6 +14,26 @@
seperator,
)

NORMAL_SHOCK_VALID_OPTIONS = [
"gamma, mach",
"gamma, P2/P1",
"gamma, Rho2/Rho1",
"gamma, T2/T1",
"gamma, P02/P01",
"gamma, P02/P1",
"gamma, dwnStrm_mach",
]


class NORMAL_SHOCK_CHOICE(Enum):
MACH = "gamma, mach"
P2_P1 = "gamma, P2/P1"
RHO2_RHO1 = "gamma, Rho2/Rho1"
T2_T1 = "gamma, T2/T1"
PO2_PO1 = "gamma, P02/P01"
PO2_P1 = "gamma, P02/P1"
M2 = "gamma, dwnStrm_mach"


class NormalShockRelations:
def __init__(
Expand Down
19 changes: 17 additions & 2 deletions CompAero/ObliqueShockRelations.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from math import sqrt, nan, pow, radians, sin, cos, atan, tan, asin, degrees, asin
from multiprocessing.sharedctypes import Value
from scipy.optimize import brenth
import matplotlib.pyplot as plt
import numpy as np
from enum import Enum

from CompAero.NormalShockRelations import NormalShockRelations
from CompAero.internal import (
Expand All @@ -18,6 +18,21 @@
)
from CompAero.greek_letters import LowerCaseGreek as lcg

class ObliqueShockChoice(Enum):
MACH_SHOCK_ANGLE = "gamma, mach, shock angle"
MACH_WEDGE_ANGLE = "gamma, mach, wedge angle"
MACH_N_1_SHOCK_ANGLE = "gamma, mach normal 1, shock angle "
M2_WEDGE_SHOCK_ANGLE = "gamma, mach behind shock (M2), wedge angle, shock angle"
P2_P1_SHOCK_ANGLE = "gamma, P2/P1, shock angle"
RHO2_RHO1_SHOCK_ANGLE = "gamma, Rho2/Rho1, shock angle"
T2_T1_SHOCK_ANGLE = "gamma, T2/T1, shock angle"
PO2_PO1_SHOCK_ANGLE = "gamma, P02/P01, shock angle"
PO2_P1_SHOCK_ANGLE = "gamma, P02/P1, shock angle"
MN2_SHOCK_ANGLE = "gamma, MN2, shock angle"

OBLIQUE_SHOCK_VALID_OPTIONS = [x.value for x in ObliqueShockChoice]


# TODO: Subclassing from the normal shock relations doesnt seem to make as much sense as it used to
# get rid of the subclassing and mach ObliqueShockRelations it's own class
class ObliqueShockRelations(NormalShockRelations):
Expand Down Expand Up @@ -140,7 +155,7 @@ def __init__(
m2, self.shockAngle, self.wedgeAngle
)
if self.machNorm2 > 1:
assert ValueError("Normal component of downstream mach number has to be less than 1")
raise ValueError("Normal component of downstream mach number has to be less than 1")
self.machNorm1 = NormalShockRelations.calc_mach_before_normal_shock_from_mach_after_shock(
self.machNorm2, self.gamma
)
Expand Down
10 changes: 10 additions & 0 deletions CompAero/PrandtlMeyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from types import DynamicClassAttribute
from scipy.optimize import brenth
from colorama import Back, Style, Fore
from enum import Enum
from CompAero.internal import (
GammaNotDefinedError,
InvalidOptionCombinationError,
Expand All @@ -15,6 +16,15 @@
from CompAero.ObliqueShockRelations import ObliqueShockRelations
from CompAero.greek_letters import LowerCaseGreek as lcg, Misc

class PrandtlMeyerChoice(Enum):
GAMMA_MACH = "gamma, mach"
GAMMA_NU = "gamma, nu"
GAMMA_MU = "gamma, mu"
GAMMA_DEFLECTION_DWN_STRM_MACH = "gamma, deflection angle, dwnStrm_mach"
GAMMA_DEFLECTION_DWN_STRM_MU = "gamma, deflection angle, dwnStrm_mu"
GAMMA_DEFLECTION_DWN_STRM_NU = "gamma, deflection angle, dwnStrm_nu"

PRANDTL_MEYER_OPTIONS = [x.value for x in PrandtlMeyerChoice]

class PrandtlMeyer:
""" This class is a collective name space for basic calculations regarding Prandtl Meyer flows.
Expand Down
12 changes: 12 additions & 0 deletions CompAero/RayleighFlowRelations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from math import sqrt, nan, pow, isnan, log
from scipy.optimize import brenth
from colorama import Back, Style, Fore
from enum import Enum
from CompAero.internal import (
FlowState,
GammaNotDefinedError,
Expand All @@ -14,6 +15,17 @@
)
from CompAero.greek_letters import LowerCaseGreek as lcg

class RayleighFlowChoice(Enum):
GAMMA_MACH = "gamma, mach"
GAMMA_T_T_ST = "gamma, T/T*, flowtype"
GAMMA_P_P_ST = "gamma, P/P*"
GAMMA_RHO_RHO_ST = "gamma, rho/rho*"
GAMMA_PO_PO_ST = "gamma, P0/P0*, flowtype"
GAMMA_TO_TO_FLOW_TYPE = "gamma, T0/T0*, flowtype"
GAMMA_U_U_ST = "gamma, U/U*"

RAYLEIGH_FLOW_VALID_OPTIONS = [x.value for x in RayleighFlowChoice]


class RayleighFlowRelations:
""" This class is a collective name space for basic calculations regarding Fanno flows.
Expand Down
8 changes: 4 additions & 4 deletions CompAero/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ def checkValue(value: Union[Union[float, int], List[Union[float, int]]]) -> bool


class FlowState(Enum):
SUB_SONIC = 1
SUPER_SONIC = 2
SUB_SONIC = "SUB_SONIC"
SUPER_SONIC = "SUPER_SONIC"


class ShockType(Enum):
WEAK = auto()
STRONG = auto()
WEAK = "WEAK"
STRONG = "STRONG"


class InvalidOptionCombinationError(Exception):
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Currently this packet is <u>not</u> available on PYPI. Install can be accomplish

```python setup.py install```

or by running

`./install.bat` on Windows machines.


### Overview

Expand All @@ -32,6 +36,13 @@ Upcoming Flows

- Conical Shocks

The package also supports a command line tool that launches a UI similiar to the Virginia Tech calculator. After installing the package this can be launched by running
`compressible_calculator` from the command line. This will launch the UI shown below.

<b><i>This is still in developement and bugs are still being fixed </i></b>

![picture](Resources/ui_picture.png)

Examples.

```python
Expand Down

0 comments on commit ed9ebae

Please sign in to comment.