steer-materials 0.1.16__tar.gz → 0.1.18__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {steer_materials-0.1.16 → steer_materials-0.1.18}/PKG-INFO +2 -2
  2. {steer_materials-0.1.16 → steer_materials-0.1.18}/pyproject.toml +2 -2
  3. steer_materials-0.1.18/steer_materials/Base.py +221 -0
  4. steer_materials-0.1.18/steer_materials/__init__.py +2 -0
  5. {steer_materials-0.1.16 → steer_materials-0.1.18}/steer_materials.egg-info/PKG-INFO +2 -2
  6. steer_materials-0.1.18/steer_materials.egg-info/SOURCES.txt +11 -0
  7. {steer_materials-0.1.16 → steer_materials-0.1.18}/steer_materials.egg-info/requires.txt +1 -1
  8. steer_materials-0.1.16/data_scripts/__init__.py +0 -0
  9. steer_materials-0.1.16/steer_materials/Base.py +0 -119
  10. steer_materials-0.1.16/steer_materials/CellMaterials/Base.py +0 -278
  11. steer_materials-0.1.16/steer_materials/CellMaterials/Electrode.py +0 -1188
  12. steer_materials-0.1.16/steer_materials/CellMaterials/__init__.py +0 -0
  13. steer_materials-0.1.16/steer_materials/Electrolytes/Electrolytes.py +0 -16
  14. steer_materials-0.1.16/steer_materials/Electrolytes/Ions.py +0 -0
  15. steer_materials-0.1.16/steer_materials/Electrolytes/Salts.py +0 -27
  16. steer_materials-0.1.16/steer_materials/Electrolytes/Solvents.py +0 -0
  17. steer_materials-0.1.16/steer_materials/Electrolytes/__init__.py +0 -0
  18. steer_materials-0.1.16/steer_materials/__init__.py +0 -6
  19. steer_materials-0.1.16/steer_materials.egg-info/SOURCES.txt +0 -29
  20. steer_materials-0.1.16/test/test_electrode_materials.py +0 -1160
  21. {steer_materials-0.1.16 → steer_materials-0.1.18}/README.md +0 -0
  22. {steer_materials-0.1.16 → steer_materials-0.1.18}/setup.cfg +0 -0
  23. {steer_materials-0.1.16 → steer_materials-0.1.18}/steer_materials.egg-info/dependency_links.txt +0 -0
  24. {steer_materials-0.1.16 → steer_materials-0.1.18}/steer_materials.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: steer-materials
3
- Version: 0.1.16
3
+ Version: 0.1.18
4
4
  Summary: Modelling energy storage from cell to site - STEER OpenCell Design
5
5
  Author-email: Nicholas Siemons <nsiemons@stanford.edu>
6
6
  Maintainer-email: Nicholas Siemons <nsiemons@stanford.edu>
@@ -22,7 +22,7 @@ Classifier: Topic :: Scientific/Engineering
22
22
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
23
  Requires-Python: >=3.10
24
24
  Description-Content-Type: text/markdown
25
- Requires-Dist: steer-core==0.1.27
25
+ Requires-Dist: steer-core==0.1.33
26
26
  Provides-Extra: dev
27
27
  Requires-Dist: pytest; extra == "dev"
28
28
  Requires-Dist: pytest-cov; extra == "dev"
@@ -31,7 +31,7 @@ classifiers = [
31
31
  ]
32
32
 
33
33
  dependencies = [
34
- "steer-core==0.1.27",
34
+ "steer-core==0.1.33",
35
35
  ]
36
36
 
37
37
  [project.optional-dependencies]
@@ -73,4 +73,4 @@ target-version = ['py310']
73
73
  testpaths = ["test"]
74
74
  python_files = "test_*.py"
75
75
  python_classes = "Test*"
76
- python_functions = "test_*"
76
+ python_functions = "test_*"
@@ -0,0 +1,221 @@
1
+ from steer_core.Constants.Units import *
2
+ from steer_core.Mixins.TypeChecker import ValidationMixin
3
+ from steer_core.Mixins.Serializer import SerializerMixin
4
+ from steer_core.Mixins.Dunder import DunderMixin
5
+
6
+ from datetime import datetime as dt
7
+
8
+ import numpy as np
9
+
10
+
11
+ class _Material(
12
+ ValidationMixin,
13
+ DunderMixin,
14
+ SerializerMixin
15
+ ):
16
+
17
+ def __init__(self, name: str, density: float, specific_cost: float, color: str):
18
+ """
19
+ Metal object for encapsulation of the cell
20
+
21
+ Parameters
22
+ ----------
23
+ name : str
24
+ Name of the material.
25
+ density : float
26
+ Density of the material in g/cm^3.
27
+ specific_cost : float
28
+ Specific cost of the material in $/kg.
29
+ color : str
30
+ Color of the material.
31
+ """
32
+ self.density = density
33
+ self.specific_cost = specific_cost
34
+ self.name = name
35
+ self.color = color
36
+
37
+ self._last_updated = dt.now()
38
+ self._update_ranges()
39
+
40
+ def _update_ranges(self):
41
+ self._density_range = (self._density * 0.9, self._density * 1.1)
42
+ self._specific_cost_range = (self._specific_cost * 0.5, self._specific_cost * 2)
43
+
44
+ @property
45
+ def density(self):
46
+ return np.round(self._density * (KG_TO_G / M_TO_CM**3), 2)
47
+
48
+ @property
49
+ def density_range(self):
50
+ return (
51
+ np.round(self._density_range[0] * (KG_TO_G / M_TO_CM**3), 2),
52
+ np.round(self._density_range[1] * (KG_TO_G / M_TO_CM**3), 2),
53
+ )
54
+
55
+ @property
56
+ def density_hard_range(self):
57
+ return (0, 100)
58
+
59
+ @property
60
+ def specific_cost(self):
61
+ return np.round(self._specific_cost, 2)
62
+
63
+ @property
64
+ def specific_cost_range(self):
65
+ return (
66
+ np.round(self._specific_cost_range[0], 2),
67
+ np.round(self._specific_cost_range[1], 2),
68
+ )
69
+
70
+ @property
71
+ def specific_cost_hard_range(self):
72
+ return (0, 1000)
73
+
74
+ @property
75
+ def name(self):
76
+ return self._name
77
+
78
+ @property
79
+ def color(self):
80
+ return self._color
81
+
82
+ @property
83
+ def last_updated(self):
84
+ return self._last_updated.strftime("%Y-%m-%d %H:%M:%S")
85
+
86
+ @color.setter
87
+ def color(self, color: str) -> None:
88
+ self.validate_string(color, "Color")
89
+ self._color = color if color else "Unknown"
90
+
91
+ @density.setter
92
+ def density(self, density: float) -> None:
93
+
94
+ # validate input
95
+ self.validate_positive_float(density, "Density")
96
+
97
+ # convert and set
98
+ self._density = density * G_TO_KG / CM_TO_M**3
99
+
100
+ # If this is a volumed material and volume is set, recalculate mass
101
+ if hasattr(self, '_volume') and self._volume is not None:
102
+ self._mass = self._volume * self._density
103
+ if hasattr(self, '_cost'):
104
+ self._cost = self._mass * self._specific_cost
105
+
106
+ @specific_cost.setter
107
+ def specific_cost(self, specific_cost: float) -> None:
108
+
109
+ # validate input
110
+ self.validate_positive_float(specific_cost, "Specific Cost")
111
+
112
+ # set value
113
+ self._specific_cost = specific_cost
114
+
115
+ # If this is a volumed material with mass, recalculate cost
116
+ if hasattr(self, '_mass') and self._mass is not None:
117
+ if hasattr(self, '_cost'):
118
+ self._cost = self._mass * self._specific_cost
119
+
120
+ @name.setter
121
+ def name(self, name: str) -> None:
122
+ self.validate_string(name, "Name")
123
+ self._name = name
124
+
125
+
126
+ class Metal(_Material):
127
+
128
+ def __init__(self, name: str, density: float, specific_cost: float, color: str):
129
+
130
+ super().__init__(name, density, specific_cost, color)
131
+
132
+
133
+ class Solvent(_Material):
134
+
135
+ def __init__(self, name: str, density: float, specific_cost: float, color: str):
136
+
137
+ super().__init__(name, density, specific_cost, color)
138
+
139
+
140
+ class _VolumedMaterialMixin:
141
+ """
142
+ Mixin for materials that optionally track volume (cm^3) or mass (kg).
143
+ Cost ($) is always derived from mass and specific_cost.
144
+ """
145
+
146
+ def __init__(
147
+ self,
148
+ *,
149
+ volume=None,
150
+ mass=None,
151
+ **kwargs
152
+ ):
153
+
154
+ super().__init__(**kwargs)
155
+
156
+ # Check that only one of volume or mass is provided
157
+ provided = sum([volume is not None, mass is not None])
158
+ if provided > 1:
159
+ raise ValueError(
160
+ "Only one of 'volume' or 'mass' can be provided during initialization. "
161
+ f"Received: volume={volume}, mass={mass}"
162
+ )
163
+
164
+ self._volume = None
165
+ self._mass = None
166
+ self._cost = None
167
+
168
+ if volume is not None:
169
+ self.volume = volume
170
+ elif mass is not None:
171
+ self.mass = mass
172
+
173
+ @property
174
+ def volume(self):
175
+ if hasattr(self, '_volume') and self._volume is not None:
176
+ return np.round(self._volume * (M_TO_CM**3), 4)
177
+ else:
178
+ return None
179
+
180
+ @property
181
+ def mass(self):
182
+ if hasattr(self, '_mass') and self._mass is not None:
183
+ return np.round(self._mass * KG_TO_G, 2)
184
+ else:
185
+ return None
186
+
187
+ @property
188
+ def cost(self):
189
+ if hasattr(self, '_cost') and self._cost is not None:
190
+ return np.round(self._cost, 2)
191
+ else:
192
+ return None
193
+
194
+
195
+ @volume.setter
196
+ def volume(self, value):
197
+
198
+ if value is not None:
199
+ ValidationMixin.validate_positive_float(value, "Volume")
200
+ self._volume = value * CM_TO_M**3
201
+ self._mass = self._volume * self._density
202
+ self._cost = self._mass * self._specific_cost
203
+ else:
204
+ self._volume = None
205
+ self._mass = None
206
+ self._cost = None
207
+
208
+ @mass.setter
209
+ def mass(self, value):
210
+
211
+ if value is not None:
212
+ ValidationMixin.validate_positive_float(value, "Mass")
213
+ self._mass = value * G_TO_KG
214
+ self._volume = self._mass / self._density
215
+ self._cost = self._mass * self._specific_cost
216
+ else:
217
+ self._volume = None
218
+ self._mass = None
219
+ self._cost = None
220
+
221
+
@@ -0,0 +1,2 @@
1
+ __version__ = "0.1.18"
2
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: steer-materials
3
- Version: 0.1.16
3
+ Version: 0.1.18
4
4
  Summary: Modelling energy storage from cell to site - STEER OpenCell Design
5
5
  Author-email: Nicholas Siemons <nsiemons@stanford.edu>
6
6
  Maintainer-email: Nicholas Siemons <nsiemons@stanford.edu>
@@ -22,7 +22,7 @@ Classifier: Topic :: Scientific/Engineering
22
22
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
23
  Requires-Python: >=3.10
24
24
  Description-Content-Type: text/markdown
25
- Requires-Dist: steer-core==0.1.27
25
+ Requires-Dist: steer-core==0.1.33
26
26
  Provides-Extra: dev
27
27
  Requires-Dist: pytest; extra == "dev"
28
28
  Requires-Dist: pytest-cov; extra == "dev"
@@ -0,0 +1,11 @@
1
+ README.md
2
+ pyproject.toml
3
+ ./steer_materials/Base.py
4
+ ./steer_materials/__init__.py
5
+ steer_materials/Base.py
6
+ steer_materials/__init__.py
7
+ steer_materials.egg-info/PKG-INFO
8
+ steer_materials.egg-info/SOURCES.txt
9
+ steer_materials.egg-info/dependency_links.txt
10
+ steer_materials.egg-info/requires.txt
11
+ steer_materials.egg-info/top_level.txt
@@ -1,4 +1,4 @@
1
- steer-core==0.1.27
1
+ steer-core==0.1.33
2
2
 
3
3
  [dev]
4
4
  pytest
File without changes
@@ -1,119 +0,0 @@
1
- from steer_core.Constants.Units import *
2
- from steer_core.Mixins.TypeChecker import ValidationMixin
3
- from steer_core.Mixins.Serializer import SerializerMixin
4
- from steer_core.Mixins.Dunder import DunderMixin
5
-
6
- from datetime import datetime as dt
7
-
8
- import numpy as np
9
-
10
-
11
- class _Material(
12
- ValidationMixin,
13
- SerializerMixin,
14
- DunderMixin
15
- ):
16
-
17
- def __init__(self, name: str, density: float, specific_cost: float, color: str):
18
- """
19
- Metal object for encapsulation of the cell
20
-
21
- Parameters
22
- ----------
23
- name : str
24
- Name of the material.
25
- density : float
26
- Density of the material in g/cm^3.
27
- specific_cost : float
28
- Specific cost of the material in $/kg.
29
- color : str
30
- Color of the material.
31
- """
32
- self.density = density
33
- self.specific_cost = specific_cost
34
- self.name = name
35
- self.color = color
36
-
37
- self._last_updated = dt.now()
38
- self._update_ranges()
39
-
40
- def _update_ranges(self):
41
- self._density_range = (self._density * 0.9, self._density * 1.1)
42
- self._specific_cost_range = (self._specific_cost * 0.5, self._specific_cost * 2)
43
-
44
- @property
45
- def density(self):
46
- return round(self._density * (KG_TO_G / M_TO_CM**3), 2)
47
-
48
- @property
49
- def density_range(self):
50
- return (
51
- round(self._density_range[0] * (KG_TO_G / M_TO_CM**3), 2),
52
- round(self._density_range[1] * (KG_TO_G / M_TO_CM**3), 2),
53
- )
54
-
55
- @property
56
- def density_hard_range(self):
57
- return (0, 100)
58
-
59
- @property
60
- def specific_cost(self):
61
- return round(self._specific_cost, 2)
62
-
63
- @property
64
- def specific_cost_range(self):
65
- return (
66
- round(self._specific_cost_range[0], 2),
67
- round(self._specific_cost_range[1], 2),
68
- )
69
-
70
- @property
71
- def specific_cost_hard_range(self):
72
- return (0, 1000)
73
-
74
- @property
75
- def name(self):
76
- return self._name
77
-
78
- @property
79
- def color(self):
80
- return self._color
81
-
82
- @property
83
- def last_updated(self):
84
- return self._last_updated.strftime("%Y-%m-%d %H:%M:%S")
85
-
86
- @color.setter
87
- def color(self, color: str) -> None:
88
- self.validate_string(color, "Color")
89
- self._color = color if color else "Unknown"
90
-
91
- @density.setter
92
- def density(self, density: float) -> None:
93
- self.validate_positive_float(density, "Density")
94
- self._density = density * G_TO_KG / CM_TO_M**3
95
-
96
- @specific_cost.setter
97
- def specific_cost(self, specific_cost: float) -> None:
98
- self.validate_positive_float(specific_cost, "Specific Cost")
99
- self._specific_cost = specific_cost
100
-
101
- @name.setter
102
- def name(self, name: str) -> None:
103
- self.validate_string(name, "Name")
104
- self._name = name
105
-
106
-
107
- class Metal(_Material):
108
-
109
- def __init__(self, name: str, density: float, specific_cost: float, color: str):
110
-
111
- super().__init__(name, density, specific_cost, color)
112
-
113
-
114
- class Solvent(_Material):
115
-
116
- def __init__(self, name: str, density: float, specific_cost: float, color: str):
117
-
118
- super().__init__(name, density, specific_cost, color)
119
-
@@ -1,278 +0,0 @@
1
- from steer_core.DataManager import DataManager
2
- from steer_core.Mixins.Serializer import SerializerMixin
3
- from steer_materials.Base import Metal, _Material
4
-
5
-
6
- class CurrentCollectorMaterial(Metal):
7
- """
8
- Materials from which current collectors are made.
9
- """
10
-
11
- def __init__(self, name: str, density: float, specific_cost: float, color: str):
12
- """
13
- Current collector material for encapsulation of the cell
14
-
15
- Parameters
16
- ----------
17
- name : str
18
- Name of the current collector material.
19
- density : float
20
- Density of the material in g/cm^3.
21
- specific_cost : float
22
- Specific cost of the material in $/kg.
23
- color : str
24
- Color of the material.
25
- """
26
- super().__init__(name, density, specific_cost, color)
27
-
28
- @staticmethod
29
- def from_database(name) -> "CurrentCollectorMaterial":
30
- """
31
- Pull object from the database.
32
-
33
- Parameters
34
- ----------
35
- name : str
36
- Name of the current collector material.
37
-
38
- Returns
39
- -------
40
- CurrentCollectorMaterial: Instance of the class.
41
-
42
- Raises
43
- ------
44
- ValueError: If the material is not found in the database.
45
- """
46
- database = DataManager()
47
-
48
- available_materials = database.get_unique_values(
49
- "current_collector_materials", "name"
50
- )
51
-
52
- if name not in available_materials:
53
- raise ValueError(
54
- f"Material '{name}' not found in the database. Available materials: {available_materials}"
55
- )
56
-
57
- data = database.get_current_collector_materials(most_recent=True).query(
58
- f"name == '{name}'"
59
- )
60
-
61
- string_rep = data["object"].iloc[0]
62
-
63
- material = SerializerMixin.deserialize(string_rep)
64
-
65
- return material
66
-
67
-
68
- class InsulationMaterial(_Material):
69
- """
70
- Materials from which insulation is made.
71
- """
72
-
73
- def __init__(self, name: str, density: float, specific_cost: float, color: str):
74
- """
75
- Insulation material for encapsulation of the cell
76
-
77
- Parameters
78
- ----------
79
- name : str
80
- Name of the insulation material.
81
- density : float
82
- Density of the material in g/cm^3.
83
- specific_cost : float
84
- Specific cost of the material in $/kg.
85
- color : str
86
- Color of the material.
87
- """
88
- super().__init__(name, density, specific_cost, color)
89
-
90
- @staticmethod
91
- def from_database(name) -> "InsulationMaterial":
92
- """
93
- Pull object from the database.
94
-
95
- Parameters
96
- ----------
97
- name : str
98
- Name of the insulation material.
99
-
100
- Returns
101
- -------
102
- InsulationMaterial: Instance of the class.
103
-
104
- Raises
105
- ------
106
- ValueError: If the material is not found in the database.
107
- """
108
- database = DataManager()
109
- available_materials = database.get_unique_values("insulation_materials", "name")
110
-
111
- if name not in available_materials:
112
- raise ValueError(
113
- f"Material '{name}' not found in the database. Available materials: {available_materials}"
114
- )
115
-
116
- data = database.get_data(table_name="insulation_materials").query(
117
- f"name == '{name}'"
118
- )
119
-
120
- string_data = data["object"].iloc[0]
121
- material = SerializerMixin.deserialize(string_data)
122
- return material
123
-
124
-
125
- class SeparatorMaterial(_Material):
126
- """
127
- Materials from which separators are made.
128
- """
129
-
130
- def __init__(
131
- self,
132
- name: str,
133
- density: float,
134
- specific_cost: float,
135
- porosity: float,
136
- color: str,
137
- ):
138
- """
139
- Separator material for encapsulation of the cell
140
-
141
- Parameters
142
- ----------
143
- name : str
144
- Name of the separator material.
145
- density : float
146
- Density of the material in g/cm^3.
147
- specific_cost : float
148
- Specific cost of the material in $/kg.
149
- porosity : float
150
- Porosity of the separator material in %.
151
- color : str
152
- Color of the material.
153
- """
154
- super().__init__(
155
- name,
156
- density,
157
- specific_cost,
158
- color
159
- )
160
-
161
- self.porosity = porosity
162
-
163
- @property
164
- def porosity(self):
165
- return round(self._porosity * 100, 2)
166
-
167
- @property
168
- def porosity_range(self):
169
- return (0, 100)
170
-
171
- @porosity.setter
172
- def porosity(self, porosity: float) -> None:
173
- self.validate_percentage(porosity, "Porosity")
174
- self._porosity = porosity / 100.0
175
-
176
- @staticmethod
177
- def from_database(name) -> "SeparatorMaterial":
178
- """
179
- Pull object from the database.
180
-
181
- Parameters
182
- ----------
183
- name : str
184
- Name of the separator material.
185
-
186
- Returns
187
- -------
188
- SeparatorMaterial: Instance of the class.
189
-
190
- Raises
191
- ------
192
- ValueError: If the material is not found in the database.
193
- """
194
- database = DataManager()
195
-
196
- available_materials = database.get_unique_values("separator_materials", "name")
197
-
198
- if name not in available_materials:
199
- raise ValueError(
200
- f"Material '{name}' not found in the database. Available materials: {available_materials}"
201
- )
202
-
203
- data = database.get_data(table_name="separator_materials").query(
204
- f"name == '{name}'"
205
- )
206
-
207
- string_data = data["object"].iloc[0]
208
- material = SerializerMixin.deserialize(string_data)
209
- return material
210
-
211
-
212
-
213
- class TapeMaterial(_Material):
214
- """
215
- Materials from which tapes are made.
216
- """
217
-
218
- def __init__(
219
- self,
220
- name: str,
221
- density: float,
222
- specific_cost: float,
223
- color: str,
224
- ):
225
- """
226
- Separator material for encapsulation of the cell
227
-
228
- Parameters
229
- ----------
230
- name : str
231
- Name of the tape material.
232
- density : float
233
- Density of the material in g/cm^3.
234
- specific_cost : float
235
- Specific cost of the material in $/kg.
236
- color : str
237
- Color of the material.
238
- """
239
- super().__init__(
240
- name,
241
- density,
242
- specific_cost,
243
- color
244
- )
245
-
246
- @staticmethod
247
- def from_database(name) -> "TapeMaterial":
248
- """
249
- Pull object from the database.
250
-
251
- Parameters
252
- ----------
253
- name : str
254
- Name of the tape material.
255
-
256
- Returns
257
- -------
258
- TapeMaterial: Instance of the class.
259
- Raises
260
- ------
261
- ValueError: If the material is not found in the database.
262
- """
263
- database = DataManager()
264
-
265
- available_materials = database.get_unique_values("tape_materials", "name")
266
-
267
- if name not in available_materials:
268
- raise ValueError(
269
- f"Material '{name}' not found in the database. Available materials: {available_materials}"
270
- )
271
-
272
- data = database.get_data(table_name="tape_materials").query(
273
- f"name == '{name}'"
274
- )
275
-
276
- string_data = data["object"].iloc[0]
277
- material = SerializerMixin.deserialize(string_data)
278
- return material