Coverage for backend/common/config_utils.py: 92%
12 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
1"""
2utility functions for defining the configuration schema
3"""
6from typing import Any,Dict
7from .config_types import *
10def dummy_unitop(displayType: str) -> ObjectType:
11 """
12 The default object type for a unit operation (if its not implemented).
13 """
14 return {
15 "displayType": displayType,
16 "ports": {},
17 "propertyPackagePorts": {},
18 "graphicObject": unitop_graphic(),
19 "propertySets": {}
20 }
23def default_property_package_ports() -> Dict[str,str]:
24 """
25 The default property package slots for a unit operation (1 property package, no name).
26 """
27 return {
28 "": ["inlet", "outlet"],
29 }
32def default_ports() -> Dict[str, PortType]:
33 """
34 The default ports for a unit operation (1 inlet, 1 outlet).
35 """
36 return {
37 "inlet": {
38 "displayName": "Inlet",
39 "type": ConType.Inlet,
40 "streamType": "stream", # Normal material streams
41 "streamName": "S"
42 },
43 "outlet": {
44 "displayName": "Outlet",
45 "type": ConType.Outlet,
46 "streamType": "stream",
47 "streamName": "S"
50 }
51 }
54def unitop_graphic() -> GraphicObjectType:
55 """
56 The default graphic object for a unit operation.
57 """
58 return {
59 "width": 100,
60 "height": 100
61 }
64def stream_graphic() -> GraphicObjectType:
65 """
66 The default graphic object for a stream.
67 """
68 return {
69 "width": 25,
70 "height": 25
71 }
73#Must only be used when the P-graph constraints are on default.
74# #Do not use if there are specific pgraph properties for constraints
75# def general_constraints() -> PropertySetType:
76# return {
77# "type": "constraints",
78# "displayName": "Constraints",
79# "containedProperties": {
80# "CmLowerBound": {
81# "displayName": "Capacity Multiplier - lower bound",
82# "type": "numeric",
83# "unitType": "currency",
84# "value": 0.0,
85# },
86# "CmUpperBound": {
87# "displayName": "Capacity Multiplier - upper bound",
88# "type": "numeric",
89# "unitType": "currency",
90# "value": 0.0,
91# },
92# "OcFix": {
93# "displayName": "Operating Cost - fix",
94# "type": "numeric",
95# "unitType": "currency",
96# "value": 0.0,
98# },
99# "OcProportional": {
100# "displayName": "Operating Cost - proportional",
101# "type": "numeric",
102# "unitType": "currency",
103# "value": 0.0,
104# },
105# "IcFix": {
106# "displayName": "Investment Cost - fix",
107# "type": "numeric",
108# "unitType": "currency",
109# "value": 0.0,
110# },
111# "IcProportional": {
112# "displayName": "Investment Cost - proportional",
113# "type": "numeric",
114# "unitType": "currency",
115# "value": 0.0,
116# },
117# },
118# }