-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathprocess_error.py
More file actions
107 lines (90 loc) · 3.47 KB
/
Copy pathprocess_error.py
File metadata and controls
107 lines (90 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from libecalc.common.errors.exceptions import EcalcError
from libecalc.process.process_pipeline.process_unit import ProcessUnitId
class ProcessError(EcalcError):
def __init__(self, reason: str | None = None):
self.reason = reason
super().__init__(title="Unable to produce an outlet stream", message=reason or "")
class CompressorSurgeError(ProcessError):
"""Compressor inlet is below its surge line. Anti-surge recirculation may recover this."""
def __init__(
self,
process_unit_id: ProcessUnitId,
actual_rate: float | None = None,
boundary_rate: float | None = None,
):
self.actual_rate = actual_rate
self.boundary_rate = boundary_rate
self.process_unit_id = process_unit_id
super().__init__(
f"Compressor {process_unit_id} is below surge line"
+ (
f": actual {actual_rate:.3f}, minimum {boundary_rate:.3f} m³/h."
if actual_rate and boundary_rate
else "."
)
)
class CompressorStonewallError(ProcessError):
"""Compressor inlet is above its stonewall limit."""
def __init__(
self,
process_unit_id: ProcessUnitId,
actual_rate: float | None = None,
boundary_rate: float | None = None,
):
self.actual_rate = actual_rate
self.boundary_rate = boundary_rate
self.process_unit_id = process_unit_id
super().__init__(
f"Compressor {process_unit_id} is above stonewall"
+ (
f": actual {actual_rate:.3f}, maximum {boundary_rate:.3f} m³/h."
if actual_rate and boundary_rate
else "."
)
)
class LiquidAtInletError(ProcessError):
def __init__(
self,
process_unit_id: ProcessUnitId,
vapor_fraction: float,
):
self.process_unit_id = process_unit_id
self.vapor_fraction = vapor_fraction
super().__init__(f"Inlet stream contains liquid (vapor fraction: {vapor_fraction:.3f})")
class NoGasPhaseError(ProcessError):
"""The stream has no gas phase — liquid removal produces nothing to compress."""
def __init__(
self,
process_unit_id: ProcessUnitId,
vapor_fraction: float,
):
self.process_unit_id = process_unit_id
self.vapor_fraction = vapor_fraction
super().__init__(f"No gas phase present (vapor fraction: {vapor_fraction:.6f})")
class OfftakeExceedsInletError(ProcessError):
def __init__(
self,
process_unit_id: ProcessUnitId,
available_rate: float,
offtake_rate: float,
):
self.process_unit_id = process_unit_id
self.available_rate = available_rate
self.offtake_rate = offtake_rate
super().__init__(
f"Inlet rate {available_rate:.3f} sm³/day is less than demanded rate {offtake_rate:.3f} sm³/day."
)
class InsufficientInletPressureError(ProcessError):
def __init__(
self,
process_unit_id: ProcessUnitId,
inlet_pressure_bara: float,
required_delta_pressure_bara: float,
):
self.process_unit_id = process_unit_id
self.inlet_pressure_bara = inlet_pressure_bara
self.required_delta_pressure_bara = required_delta_pressure_bara
super().__init__(
f"Inlet pressure {inlet_pressure_bara:.3f} bara is insufficient for required pressure drop "
f"{required_delta_pressure_bara:.3f} bara."
)