greemat 1.0.0__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.
- greemat-1.0.0/LICENSE +6 -0
- greemat-1.0.0/PKG-INFO +278 -0
- greemat-1.0.0/README.md +262 -0
- greemat-1.0.0/pyproject.toml +37 -0
- greemat-1.0.0/setup.cfg +4 -0
- greemat-1.0.0/src/greemat/__init__.py +5 -0
- greemat-1.0.0/src/greemat/assets/banner.gif +0 -0
- greemat-1.0.0/src/greemat/assets/icon.gif +0 -0
- greemat-1.0.0/src/greemat/assets/splash.gif +0 -0
- greemat-1.0.0/src/greemat/data/h_phrases.json +210 -0
- greemat-1.0.0/src/greemat/data/wastes.json +38 -0
- greemat-1.0.0/src/greemat/gui.py +1577 -0
- greemat-1.0.0/src/greemat/streams.py +150 -0
- greemat-1.0.0/src/greemat/synthesis.py +619 -0
- greemat-1.0.0/src/greemat/utils.py +55 -0
- greemat-1.0.0/src/greemat.egg-info/PKG-INFO +278 -0
- greemat-1.0.0/src/greemat.egg-info/SOURCES.txt +19 -0
- greemat-1.0.0/src/greemat.egg-info/dependency_links.txt +1 -0
- greemat-1.0.0/src/greemat.egg-info/entry_points.txt +2 -0
- greemat-1.0.0/src/greemat.egg-info/requires.txt +2 -0
- greemat-1.0.0/src/greemat.egg-info/top_level.txt +1 -0
greemat-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Copyright (c) 2026 Jesus Alberto Martin del Campo
|
|
2
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
3
|
+
|
|
4
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
5
|
+
|
|
6
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
greemat-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: greemat
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Green metrics for materials synthesis
|
|
5
|
+
Author-email: Jesus Alberto Martin del Campo <jesus-alberto.martin-del-campo@uib.cat>
|
|
6
|
+
Project-URL: Homepage, https://github.com/jesusalmartin/greemat
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: numpy>=1.21
|
|
14
|
+
Requires-Dist: matplotlib>=3.5
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# GREEMAT: Green Metrics for Materials Synthesis
|
|
19
|
+
|
|
20
|
+
**GREEMAT** (GREEn Metrics for MATerials synthesis) is a free, open‑source software tool designed to assess the environmental greenness of chemical syntheses of functional materials such as metal–organic frameworks (MOFs), catalysts, and adsorbents. It implements an eight‑criterion metric system grounded in the twelve principles of green chemistry, translating qualitative principles into quantitative, transparent, and reproducible assessments.
|
|
21
|
+
|
|
22
|
+
The software provides two complementary interfaces:
|
|
23
|
+
|
|
24
|
+
- **A graphical user interface (GUI)** suitable for bench chemists who wish to evaluate or compare synthetic routes interactively, without any programming knowledge.
|
|
25
|
+
- **A Python library** for users who need to integrate greenness assessment into automated workflows, Jupyter notebooks, or batch processing of many syntheses.
|
|
26
|
+
|
|
27
|
+
Both interfaces share the same calculation engine and the same JSON file format, so assessments can be started in the GUI, refined in a script, and shared with collaborators.
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- **Comprehensive Stream Management**: Define material inputs (with GHS H‑phrases for hazard assessment), waste outputs (categorized by impact), and energy sources (with power consumption) for each process step.
|
|
32
|
+
|
|
33
|
+
- **Functional Normalisation**: Unlike conventional mass‑based metrics, GREEMAT normalises all inputs, wastes, and energy by a user‑defined **functional output** (e.g., mg of pollutant adsorbed, mmol of product formed, or turnover number). This enables meaningful comparisons between syntheses that yield materials with different specific performances.
|
|
34
|
+
|
|
35
|
+
- **Eight Green Metrics Criteria**:
|
|
36
|
+
- Waste Prevention
|
|
37
|
+
- Material Efficiency
|
|
38
|
+
- Hazard Intensity
|
|
39
|
+
- Recyclability
|
|
40
|
+
- Energy Intensity
|
|
41
|
+
- Renewable Content
|
|
42
|
+
- Process Simplicity
|
|
43
|
+
- In‑Process Monitoring
|
|
44
|
+
|
|
45
|
+
- **Flexible Scoring System**: Each criterion is transformed into a score from 0 (least green) to 1 (most green) using user‑adjustable thresholds and transformation types (linear, logarithmic, or exponential).
|
|
46
|
+
|
|
47
|
+
- **Customisable Weights**: Each criterion can be assigned a weight (0–5) to reflect its importance in a given context. Default weights are provided based on expert judgement.
|
|
48
|
+
|
|
49
|
+
- **Interactive GUI**: A `tkinter`‑based interface for managing streams, building synthesis steps, configuring scoring thresholds, and adjusting metric weights.
|
|
50
|
+
|
|
51
|
+
- **Professional Visualisation**: Generates circular pictograms using `matplotlib` to visualise performance across all criteria at a glance, with the overall weighted score displayed in the centre.
|
|
52
|
+
|
|
53
|
+
- **Data Persistence and Reproducibility**: Save and load complete assessments in JSON format. The schema is fully documented, lossless, and interchangeable between the GUI and the Python library, ensuring transparent and reproducible evaluations.
|
|
54
|
+
|
|
55
|
+
- **Open Source**: Released under the MIT License. Source code is available on GitHub.
|
|
56
|
+
|
|
57
|
+
## Project Structure
|
|
58
|
+
|
|
59
|
+
The project is organised into several key modules:
|
|
60
|
+
|
|
61
|
+
| Module | Description |
|
|
62
|
+
|--------|-------------|
|
|
63
|
+
| `gui.py` | Implements the `GreenMetricsGUI` class, handling all user interactions, tab management, and plotting. |
|
|
64
|
+
| `synthesis.py` | Contains the core logic, including the `Step` class (representing individual process stages) and the `Synthesis` class (aggregating data and calculating scores). |
|
|
65
|
+
| `streams.py` | Defines the `Material`, `Waste`, and `Energy` classes, including penalty logic for H‑phrases and waste categories. |
|
|
66
|
+
| `utils.py` | Utility functions for managing package paths and loading external assets and data. |
|
|
67
|
+
| `__init__.py` | Package initialisation and versioning. |
|
|
68
|
+
|
|
69
|
+
## Requirements
|
|
70
|
+
|
|
71
|
+
To run GREEMAT, you need:
|
|
72
|
+
|
|
73
|
+
- **Python 3.7 or higher**
|
|
74
|
+
- **Dependencies**:
|
|
75
|
+
- `numpy`
|
|
76
|
+
- `matplotlib`
|
|
77
|
+
- `tkinter` (standard with most Python distributions on Windows, Linux, and macOS)
|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
### Option 1: Install from PyPI (recommended)
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install greemat
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Option 2: Install from source (for development or latest version)
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
git clone https://github.com/jesusalmartin/greemat.git
|
|
91
|
+
cd greemat
|
|
92
|
+
pip install -e .
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Option 3: Windows Portable Executable (no installation required)
|
|
96
|
+
|
|
97
|
+
Download the `GREEMAT.exe` file (approx. 40 MB) from the [Releases](https://github.com/jesusalmartin/greemat/releases) section. No administrator privileges are needed—simply double‑click to launch the application.
|
|
98
|
+
|
|
99
|
+
> **Note:** Some antivirus software may flag new `.exe` files. GREEMAT is open‑source and benign; you can verify the source code or temporarily add an exception.
|
|
100
|
+
|
|
101
|
+
## Usage
|
|
102
|
+
|
|
103
|
+
### Running the GUI
|
|
104
|
+
|
|
105
|
+
If installed via `pip`, launch the GUI from the terminal:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
greemat
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Alternatively, run the module directly:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
python -m greemat.gui
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The GUI allows you to:
|
|
118
|
+
|
|
119
|
+
1. **Define Streams**: Add materials (selecting GHS H‑phrases for hazard assessment), wastes (selecting waste categories), and energy sources (with power consumption in watts).
|
|
120
|
+
2. **Build Synthesis Steps**: Organise streams into sequential steps, specifying amounts (grams) and operation times (hours).
|
|
121
|
+
3. **Configure Scoring**: Adjust scoring thresholds (Settings → Scoring Setup) and criterion weights (Synthesis tab) to suit your context.
|
|
122
|
+
4. **Calculate and Visualise**: Compute the green scores and generate a circular pictogram (Show Plot). Export the plot as PNG (File → Export Plot).
|
|
123
|
+
|
|
124
|
+
### Using as a Python Library
|
|
125
|
+
|
|
126
|
+
GREEMAT can be seamlessly integrated into scripts, Jupyter notebooks, or automated workflows. The library revolves around four main classes: `Material`, `Waste`, `Energy`, `Step`, and `Synthesis`.
|
|
127
|
+
|
|
128
|
+
**Example: Assessing a ZIF‑8 Synthesis**
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from greemat.streams import Material, Energy, Waste
|
|
132
|
+
from greemat.synthesis import Step, Synthesis
|
|
133
|
+
|
|
134
|
+
# --- Define reusable streams ---
|
|
135
|
+
|
|
136
|
+
# Materials
|
|
137
|
+
zn_acet = Material('Zinc acetate', ['H302', 'H318', 'H411'])
|
|
138
|
+
ligand = Material('2-Methylimidazole', ['H302', 'H314', 'H351', 'H360d', 'H360f'])
|
|
139
|
+
water = Material('Water', []) # no hazard phrases
|
|
140
|
+
|
|
141
|
+
# Energy
|
|
142
|
+
stirrer = Energy('Stirrer', 30) # 30 W
|
|
143
|
+
centrifuge = Energy('Centrifuge', 500) # 500 W
|
|
144
|
+
|
|
145
|
+
# Wastes
|
|
146
|
+
met_sol = Waste('Heavy metals', '7') # category 7: heavy metal waste
|
|
147
|
+
aq_sol = Waste('Aqueous solution', '3') # category 3: aqueous non‑hazardous
|
|
148
|
+
|
|
149
|
+
# --- Build synthesis steps ---
|
|
150
|
+
|
|
151
|
+
# Step 1: Synthesis reaction
|
|
152
|
+
step1 = Step('Synthesis', monitoring=False)
|
|
153
|
+
step1.add_material(ligand, 10.8) # grams
|
|
154
|
+
step1.add_material(zn_acet, 2.93)
|
|
155
|
+
step1.add_material(water, 75)
|
|
156
|
+
step1.add_energy(stirrer, 24) # 24 hours
|
|
157
|
+
step1.add_waste(met_sol, 75) # waste mass in grams
|
|
158
|
+
|
|
159
|
+
# Step 2: Washing
|
|
160
|
+
step2 = Step('Washing', monitoring=False)
|
|
161
|
+
step2.add_material(water, 75)
|
|
162
|
+
step2.add_energy(centrifuge, 0.25) # 15 minutes
|
|
163
|
+
step2.add_waste(aq_sol, 75)
|
|
164
|
+
|
|
165
|
+
# --- Create synthesis with functional output ---
|
|
166
|
+
|
|
167
|
+
synth = Synthesis(
|
|
168
|
+
product_name='ZIF-8-RT-H2O',
|
|
169
|
+
functional_output=13.4, # mg BPA adsorbed per batch
|
|
170
|
+
functional_unit_name='mg BPA adsorbed / batch',
|
|
171
|
+
cycles=5 # reuse cycles
|
|
172
|
+
)
|
|
173
|
+
synth.add_steps([step1, step2])
|
|
174
|
+
|
|
175
|
+
# --- Compute green scores ---
|
|
176
|
+
|
|
177
|
+
scores, raw_metrics = synth.green_scores(get_metric_values=True)
|
|
178
|
+
print(f"Overall weighted score: {scores['overall_weighted']:.3f}")
|
|
179
|
+
|
|
180
|
+
# --- Generate and display the circular pictogram ---
|
|
181
|
+
|
|
182
|
+
fig = synth.get_green_scores_plot()
|
|
183
|
+
fig.show()
|
|
184
|
+
|
|
185
|
+
# --- Save and load assessment ---
|
|
186
|
+
|
|
187
|
+
synth.save('my_assessment.json')
|
|
188
|
+
loaded_synth = Synthesis.load('my_assessment.json')
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Customising Scoring Thresholds and Weights
|
|
192
|
+
|
|
193
|
+
Each criterion has a scoring function that maps a raw metric value $x$ to a score $s$ using three parameters:
|
|
194
|
+
|
|
195
|
+
- `x_good`: the raw value that yields a score of 1 (greenest)
|
|
196
|
+
- `x_bad`: the raw value that yields a score of 0 (least green)
|
|
197
|
+
- `type`: transformation type: `"linear"`, `"log"`, or `"exp"`
|
|
198
|
+
|
|
199
|
+
**Example: Custom thresholds in Python**
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
score_setup = {
|
|
203
|
+
'waste_prevention': {'x_good': 10.0, 'x_bad': 600.0, 'type': 'log'},
|
|
204
|
+
'material_efficiency': {'x_good': 10.0, 'x_bad': 600.0, 'type': 'log'},
|
|
205
|
+
'hazard_intensity': {'x_good': 1.0, 'x_bad': 20.0, 'type': 'log'},
|
|
206
|
+
'reusability': {'x_good': 5.0, 'x_bad': 1.0, 'type': 'linear'},
|
|
207
|
+
'energy_intensity': {'x_good': 10.0, 'x_bad': 8500.0, 'type': 'log'},
|
|
208
|
+
'renewable_content': {'x_good': 0.75, 'x_bad': 0.05, 'type': 'log'},
|
|
209
|
+
'process_simplicity': {'x_good': 3.0, 'x_bad': 10.0, 'type': 'linear'},
|
|
210
|
+
'monitoring': {'x_good': 1.0, 'x_bad': 0.0, 'type': 'linear'}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
synth.score_setup = score_setup
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Weights** (integers from 0 to 5) can be assigned to each criterion:
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
synth.weights = {
|
|
220
|
+
'waste_prevention': 3,
|
|
221
|
+
'material_efficiency': 4,
|
|
222
|
+
'hazard_intensity': 3,
|
|
223
|
+
'reusability': 2,
|
|
224
|
+
'energy_intensity': 3,
|
|
225
|
+
'renewable_content': 0,
|
|
226
|
+
'process_simplicity': 0,
|
|
227
|
+
'monitoring': 0
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
> **Important note on comparability:** Scores are meaningful only when compared across assessments that use **exactly the same scoring thresholds** (x_good, x_bad, type) **and** the **same weights**. Always report the `score_setup` and `weights` used, and keep them constant across compared procedures. The JSON file automatically records these settings.
|
|
232
|
+
|
|
233
|
+
## Data and Assets
|
|
234
|
+
|
|
235
|
+
- **Hazard Phrases**: Hazard penalties are determined by codes in `data/h_phrases.json`, following the penalty system of Tobiszewski et al. (*Green Chem.*, 2017).
|
|
236
|
+
- **Waste Categories**: Waste impact is calculated based on classifications in `data/wastes.json`, derived from the European Waste Catalogue.
|
|
237
|
+
- **UI Assets**: Icons and banners are located in the `assets/` directory.
|
|
238
|
+
|
|
239
|
+
## JSON File Format
|
|
240
|
+
|
|
241
|
+
GREEMAT uses a JSON‑based file format to store complete assessments. This format is human‑readable, can be version‑controlled (e.g., with Git), and is fully compatible between the GUI and the Python library.
|
|
242
|
+
|
|
243
|
+
A GREEMAT JSON file contains the following top‑level fields:
|
|
244
|
+
|
|
245
|
+
| **Field** | **Type** | **Description** |
|
|
246
|
+
|-----------|----------|-----------------|
|
|
247
|
+
| `product_name` | *string* | Name of the final material |
|
|
248
|
+
| `functional_output` | *float* | Total functional output delivered |
|
|
249
|
+
| `functional_unit_name` | *string* | Descriptive name of the functional unit |
|
|
250
|
+
| `cycles` | *integer* | Number of reuse cycles |
|
|
251
|
+
| `score_setup` | *object* | Per‑criterion scoring thresholds (x_good, x_bad, type) |
|
|
252
|
+
| `weights` | *object* | User‑defined weights for the eight criteria |
|
|
253
|
+
| `materials` | *array* | List of material stream definitions |
|
|
254
|
+
| `wastes` | *array* | List of waste stream definitions |
|
|
255
|
+
| `energies` | *array* | List of energy stream definitions |
|
|
256
|
+
| `steps` | *array* | List of synthesis steps, each referencing the defined streams |
|
|
257
|
+
|
|
258
|
+
A full schema description is provided in the Supporting Information of the GREEMAT paper.
|
|
259
|
+
|
|
260
|
+
## License
|
|
261
|
+
|
|
262
|
+
GREEMAT is released under the **MIT License**, a permissive open‑source license that allows anyone to use, modify, and distribute the software for any purpose, provided the original copyright notice and license text are included.
|
|
263
|
+
|
|
264
|
+
## Citation
|
|
265
|
+
|
|
266
|
+
If you use GREEMAT in your research, please cite the associated paper.
|
|
267
|
+
|
|
268
|
+
For the software itself, please check the repository README for the most up‑to‑date DOI and citation format.
|
|
269
|
+
|
|
270
|
+
## Acknowledgements
|
|
271
|
+
|
|
272
|
+
The authors acknowledge financial support from the project PID2024–159827OB-I00, funded by the Spanish Ministry of Science, Innovation and Universities, through the State Research Agency MICIU/AEI/10.13039/501100011033/FEDER, EU.
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
**Repository:** [https://github.com/jesusalmartin/greemat](https://github.com/jesusalmartin/greemat)
|
|
278
|
+
**Documentation:** Full documentation, including a step-by-step GUI guide, Python library reference, and JSON schema details, is available in the [manual](docs/MANUAL.md).
|
greemat-1.0.0/README.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
|
|
2
|
+
# GREEMAT: Green Metrics for Materials Synthesis
|
|
3
|
+
|
|
4
|
+
**GREEMAT** (GREEn Metrics for MATerials synthesis) is a free, open‑source software tool designed to assess the environmental greenness of chemical syntheses of functional materials such as metal–organic frameworks (MOFs), catalysts, and adsorbents. It implements an eight‑criterion metric system grounded in the twelve principles of green chemistry, translating qualitative principles into quantitative, transparent, and reproducible assessments.
|
|
5
|
+
|
|
6
|
+
The software provides two complementary interfaces:
|
|
7
|
+
|
|
8
|
+
- **A graphical user interface (GUI)** suitable for bench chemists who wish to evaluate or compare synthetic routes interactively, without any programming knowledge.
|
|
9
|
+
- **A Python library** for users who need to integrate greenness assessment into automated workflows, Jupyter notebooks, or batch processing of many syntheses.
|
|
10
|
+
|
|
11
|
+
Both interfaces share the same calculation engine and the same JSON file format, so assessments can be started in the GUI, refined in a script, and shared with collaborators.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Comprehensive Stream Management**: Define material inputs (with GHS H‑phrases for hazard assessment), waste outputs (categorized by impact), and energy sources (with power consumption) for each process step.
|
|
16
|
+
|
|
17
|
+
- **Functional Normalisation**: Unlike conventional mass‑based metrics, GREEMAT normalises all inputs, wastes, and energy by a user‑defined **functional output** (e.g., mg of pollutant adsorbed, mmol of product formed, or turnover number). This enables meaningful comparisons between syntheses that yield materials with different specific performances.
|
|
18
|
+
|
|
19
|
+
- **Eight Green Metrics Criteria**:
|
|
20
|
+
- Waste Prevention
|
|
21
|
+
- Material Efficiency
|
|
22
|
+
- Hazard Intensity
|
|
23
|
+
- Recyclability
|
|
24
|
+
- Energy Intensity
|
|
25
|
+
- Renewable Content
|
|
26
|
+
- Process Simplicity
|
|
27
|
+
- In‑Process Monitoring
|
|
28
|
+
|
|
29
|
+
- **Flexible Scoring System**: Each criterion is transformed into a score from 0 (least green) to 1 (most green) using user‑adjustable thresholds and transformation types (linear, logarithmic, or exponential).
|
|
30
|
+
|
|
31
|
+
- **Customisable Weights**: Each criterion can be assigned a weight (0–5) to reflect its importance in a given context. Default weights are provided based on expert judgement.
|
|
32
|
+
|
|
33
|
+
- **Interactive GUI**: A `tkinter`‑based interface for managing streams, building synthesis steps, configuring scoring thresholds, and adjusting metric weights.
|
|
34
|
+
|
|
35
|
+
- **Professional Visualisation**: Generates circular pictograms using `matplotlib` to visualise performance across all criteria at a glance, with the overall weighted score displayed in the centre.
|
|
36
|
+
|
|
37
|
+
- **Data Persistence and Reproducibility**: Save and load complete assessments in JSON format. The schema is fully documented, lossless, and interchangeable between the GUI and the Python library, ensuring transparent and reproducible evaluations.
|
|
38
|
+
|
|
39
|
+
- **Open Source**: Released under the MIT License. Source code is available on GitHub.
|
|
40
|
+
|
|
41
|
+
## Project Structure
|
|
42
|
+
|
|
43
|
+
The project is organised into several key modules:
|
|
44
|
+
|
|
45
|
+
| Module | Description |
|
|
46
|
+
|--------|-------------|
|
|
47
|
+
| `gui.py` | Implements the `GreenMetricsGUI` class, handling all user interactions, tab management, and plotting. |
|
|
48
|
+
| `synthesis.py` | Contains the core logic, including the `Step` class (representing individual process stages) and the `Synthesis` class (aggregating data and calculating scores). |
|
|
49
|
+
| `streams.py` | Defines the `Material`, `Waste`, and `Energy` classes, including penalty logic for H‑phrases and waste categories. |
|
|
50
|
+
| `utils.py` | Utility functions for managing package paths and loading external assets and data. |
|
|
51
|
+
| `__init__.py` | Package initialisation and versioning. |
|
|
52
|
+
|
|
53
|
+
## Requirements
|
|
54
|
+
|
|
55
|
+
To run GREEMAT, you need:
|
|
56
|
+
|
|
57
|
+
- **Python 3.7 or higher**
|
|
58
|
+
- **Dependencies**:
|
|
59
|
+
- `numpy`
|
|
60
|
+
- `matplotlib`
|
|
61
|
+
- `tkinter` (standard with most Python distributions on Windows, Linux, and macOS)
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
### Option 1: Install from PyPI (recommended)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install greemat
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Option 2: Install from source (for development or latest version)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git clone https://github.com/jesusalmartin/greemat.git
|
|
75
|
+
cd greemat
|
|
76
|
+
pip install -e .
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Option 3: Windows Portable Executable (no installation required)
|
|
80
|
+
|
|
81
|
+
Download the `GREEMAT.exe` file (approx. 40 MB) from the [Releases](https://github.com/jesusalmartin/greemat/releases) section. No administrator privileges are needed—simply double‑click to launch the application.
|
|
82
|
+
|
|
83
|
+
> **Note:** Some antivirus software may flag new `.exe` files. GREEMAT is open‑source and benign; you can verify the source code or temporarily add an exception.
|
|
84
|
+
|
|
85
|
+
## Usage
|
|
86
|
+
|
|
87
|
+
### Running the GUI
|
|
88
|
+
|
|
89
|
+
If installed via `pip`, launch the GUI from the terminal:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
greemat
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Alternatively, run the module directly:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
python -m greemat.gui
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The GUI allows you to:
|
|
102
|
+
|
|
103
|
+
1. **Define Streams**: Add materials (selecting GHS H‑phrases for hazard assessment), wastes (selecting waste categories), and energy sources (with power consumption in watts).
|
|
104
|
+
2. **Build Synthesis Steps**: Organise streams into sequential steps, specifying amounts (grams) and operation times (hours).
|
|
105
|
+
3. **Configure Scoring**: Adjust scoring thresholds (Settings → Scoring Setup) and criterion weights (Synthesis tab) to suit your context.
|
|
106
|
+
4. **Calculate and Visualise**: Compute the green scores and generate a circular pictogram (Show Plot). Export the plot as PNG (File → Export Plot).
|
|
107
|
+
|
|
108
|
+
### Using as a Python Library
|
|
109
|
+
|
|
110
|
+
GREEMAT can be seamlessly integrated into scripts, Jupyter notebooks, or automated workflows. The library revolves around four main classes: `Material`, `Waste`, `Energy`, `Step`, and `Synthesis`.
|
|
111
|
+
|
|
112
|
+
**Example: Assessing a ZIF‑8 Synthesis**
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from greemat.streams import Material, Energy, Waste
|
|
116
|
+
from greemat.synthesis import Step, Synthesis
|
|
117
|
+
|
|
118
|
+
# --- Define reusable streams ---
|
|
119
|
+
|
|
120
|
+
# Materials
|
|
121
|
+
zn_acet = Material('Zinc acetate', ['H302', 'H318', 'H411'])
|
|
122
|
+
ligand = Material('2-Methylimidazole', ['H302', 'H314', 'H351', 'H360d', 'H360f'])
|
|
123
|
+
water = Material('Water', []) # no hazard phrases
|
|
124
|
+
|
|
125
|
+
# Energy
|
|
126
|
+
stirrer = Energy('Stirrer', 30) # 30 W
|
|
127
|
+
centrifuge = Energy('Centrifuge', 500) # 500 W
|
|
128
|
+
|
|
129
|
+
# Wastes
|
|
130
|
+
met_sol = Waste('Heavy metals', '7') # category 7: heavy metal waste
|
|
131
|
+
aq_sol = Waste('Aqueous solution', '3') # category 3: aqueous non‑hazardous
|
|
132
|
+
|
|
133
|
+
# --- Build synthesis steps ---
|
|
134
|
+
|
|
135
|
+
# Step 1: Synthesis reaction
|
|
136
|
+
step1 = Step('Synthesis', monitoring=False)
|
|
137
|
+
step1.add_material(ligand, 10.8) # grams
|
|
138
|
+
step1.add_material(zn_acet, 2.93)
|
|
139
|
+
step1.add_material(water, 75)
|
|
140
|
+
step1.add_energy(stirrer, 24) # 24 hours
|
|
141
|
+
step1.add_waste(met_sol, 75) # waste mass in grams
|
|
142
|
+
|
|
143
|
+
# Step 2: Washing
|
|
144
|
+
step2 = Step('Washing', monitoring=False)
|
|
145
|
+
step2.add_material(water, 75)
|
|
146
|
+
step2.add_energy(centrifuge, 0.25) # 15 minutes
|
|
147
|
+
step2.add_waste(aq_sol, 75)
|
|
148
|
+
|
|
149
|
+
# --- Create synthesis with functional output ---
|
|
150
|
+
|
|
151
|
+
synth = Synthesis(
|
|
152
|
+
product_name='ZIF-8-RT-H2O',
|
|
153
|
+
functional_output=13.4, # mg BPA adsorbed per batch
|
|
154
|
+
functional_unit_name='mg BPA adsorbed / batch',
|
|
155
|
+
cycles=5 # reuse cycles
|
|
156
|
+
)
|
|
157
|
+
synth.add_steps([step1, step2])
|
|
158
|
+
|
|
159
|
+
# --- Compute green scores ---
|
|
160
|
+
|
|
161
|
+
scores, raw_metrics = synth.green_scores(get_metric_values=True)
|
|
162
|
+
print(f"Overall weighted score: {scores['overall_weighted']:.3f}")
|
|
163
|
+
|
|
164
|
+
# --- Generate and display the circular pictogram ---
|
|
165
|
+
|
|
166
|
+
fig = synth.get_green_scores_plot()
|
|
167
|
+
fig.show()
|
|
168
|
+
|
|
169
|
+
# --- Save and load assessment ---
|
|
170
|
+
|
|
171
|
+
synth.save('my_assessment.json')
|
|
172
|
+
loaded_synth = Synthesis.load('my_assessment.json')
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Customising Scoring Thresholds and Weights
|
|
176
|
+
|
|
177
|
+
Each criterion has a scoring function that maps a raw metric value $x$ to a score $s$ using three parameters:
|
|
178
|
+
|
|
179
|
+
- `x_good`: the raw value that yields a score of 1 (greenest)
|
|
180
|
+
- `x_bad`: the raw value that yields a score of 0 (least green)
|
|
181
|
+
- `type`: transformation type: `"linear"`, `"log"`, or `"exp"`
|
|
182
|
+
|
|
183
|
+
**Example: Custom thresholds in Python**
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
score_setup = {
|
|
187
|
+
'waste_prevention': {'x_good': 10.0, 'x_bad': 600.0, 'type': 'log'},
|
|
188
|
+
'material_efficiency': {'x_good': 10.0, 'x_bad': 600.0, 'type': 'log'},
|
|
189
|
+
'hazard_intensity': {'x_good': 1.0, 'x_bad': 20.0, 'type': 'log'},
|
|
190
|
+
'reusability': {'x_good': 5.0, 'x_bad': 1.0, 'type': 'linear'},
|
|
191
|
+
'energy_intensity': {'x_good': 10.0, 'x_bad': 8500.0, 'type': 'log'},
|
|
192
|
+
'renewable_content': {'x_good': 0.75, 'x_bad': 0.05, 'type': 'log'},
|
|
193
|
+
'process_simplicity': {'x_good': 3.0, 'x_bad': 10.0, 'type': 'linear'},
|
|
194
|
+
'monitoring': {'x_good': 1.0, 'x_bad': 0.0, 'type': 'linear'}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
synth.score_setup = score_setup
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Weights** (integers from 0 to 5) can be assigned to each criterion:
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
synth.weights = {
|
|
204
|
+
'waste_prevention': 3,
|
|
205
|
+
'material_efficiency': 4,
|
|
206
|
+
'hazard_intensity': 3,
|
|
207
|
+
'reusability': 2,
|
|
208
|
+
'energy_intensity': 3,
|
|
209
|
+
'renewable_content': 0,
|
|
210
|
+
'process_simplicity': 0,
|
|
211
|
+
'monitoring': 0
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
> **Important note on comparability:** Scores are meaningful only when compared across assessments that use **exactly the same scoring thresholds** (x_good, x_bad, type) **and** the **same weights**. Always report the `score_setup` and `weights` used, and keep them constant across compared procedures. The JSON file automatically records these settings.
|
|
216
|
+
|
|
217
|
+
## Data and Assets
|
|
218
|
+
|
|
219
|
+
- **Hazard Phrases**: Hazard penalties are determined by codes in `data/h_phrases.json`, following the penalty system of Tobiszewski et al. (*Green Chem.*, 2017).
|
|
220
|
+
- **Waste Categories**: Waste impact is calculated based on classifications in `data/wastes.json`, derived from the European Waste Catalogue.
|
|
221
|
+
- **UI Assets**: Icons and banners are located in the `assets/` directory.
|
|
222
|
+
|
|
223
|
+
## JSON File Format
|
|
224
|
+
|
|
225
|
+
GREEMAT uses a JSON‑based file format to store complete assessments. This format is human‑readable, can be version‑controlled (e.g., with Git), and is fully compatible between the GUI and the Python library.
|
|
226
|
+
|
|
227
|
+
A GREEMAT JSON file contains the following top‑level fields:
|
|
228
|
+
|
|
229
|
+
| **Field** | **Type** | **Description** |
|
|
230
|
+
|-----------|----------|-----------------|
|
|
231
|
+
| `product_name` | *string* | Name of the final material |
|
|
232
|
+
| `functional_output` | *float* | Total functional output delivered |
|
|
233
|
+
| `functional_unit_name` | *string* | Descriptive name of the functional unit |
|
|
234
|
+
| `cycles` | *integer* | Number of reuse cycles |
|
|
235
|
+
| `score_setup` | *object* | Per‑criterion scoring thresholds (x_good, x_bad, type) |
|
|
236
|
+
| `weights` | *object* | User‑defined weights for the eight criteria |
|
|
237
|
+
| `materials` | *array* | List of material stream definitions |
|
|
238
|
+
| `wastes` | *array* | List of waste stream definitions |
|
|
239
|
+
| `energies` | *array* | List of energy stream definitions |
|
|
240
|
+
| `steps` | *array* | List of synthesis steps, each referencing the defined streams |
|
|
241
|
+
|
|
242
|
+
A full schema description is provided in the Supporting Information of the GREEMAT paper.
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
GREEMAT is released under the **MIT License**, a permissive open‑source license that allows anyone to use, modify, and distribute the software for any purpose, provided the original copyright notice and license text are included.
|
|
247
|
+
|
|
248
|
+
## Citation
|
|
249
|
+
|
|
250
|
+
If you use GREEMAT in your research, please cite the associated paper.
|
|
251
|
+
|
|
252
|
+
For the software itself, please check the repository README for the most up‑to‑date DOI and citation format.
|
|
253
|
+
|
|
254
|
+
## Acknowledgements
|
|
255
|
+
|
|
256
|
+
The authors acknowledge financial support from the project PID2024–159827OB-I00, funded by the Spanish Ministry of Science, Innovation and Universities, through the State Research Agency MICIU/AEI/10.13039/501100011033/FEDER, EU.
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
**Repository:** [https://github.com/jesusalmartin/greemat](https://github.com/jesusalmartin/greemat)
|
|
262
|
+
**Documentation:** Full documentation, including a step-by-step GUI guide, Python library reference, and JSON schema details, is available in the [manual](docs/MANUAL.md).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "greemat"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Jesus Alberto Martin del Campo", email = "jesus-alberto.martin-del-campo@uib.cat" },
|
|
10
|
+
]
|
|
11
|
+
description = "Green metrics for materials synthesis"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"numpy>=1.21",
|
|
21
|
+
"matplotlib>=3.5",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
"Homepage" = "https://github.com/jesusalmartin/greemat"
|
|
26
|
+
|
|
27
|
+
[project.scripts]
|
|
28
|
+
greemat = "greemat.gui:main"
|
|
29
|
+
|
|
30
|
+
[tool.setuptools]
|
|
31
|
+
# Esto le dice a setuptools que busque el código dentro de la carpeta 'src'
|
|
32
|
+
packages = {find = {where = ["src"]}}
|
|
33
|
+
include-package-data = true
|
|
34
|
+
|
|
35
|
+
[tool.setuptools.package-data]
|
|
36
|
+
# Asegura que tus JSON y GIFs se incluyan al empaquetar
|
|
37
|
+
greemat = ["data/*.json", "assets/*.gif"]
|
greemat-1.0.0/setup.cfg
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|