You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,24 @@
1
1
# Micro Manager changelog
2
2
3
+
## v0.7.0
4
+
5
+
- Share similarity distance matrix between ranks on a compute node https://github.com/precice/micro-manager/pull/176
6
+
- Use booleans instead of strings `"True"` and `"False"` in the configuration https://github.com/precice/micro-manager/pull/175
7
+
- Renaming and using a newer workflow for publishing according to the trusted publishing in PyPI https://github.com/precice/micro-manager/pull/173
8
+
- Add config options for adaptivity metrics and memory usage output to allow for different levels https://github.com/precice/micro-manager/pull/172
9
+
- Fix bug in adaptivity computation when an active simulation with associations is deactivated https://github.com/precice/micro-manager/pull/171
10
+
- Properly handle micro simulation initialization for lazy initialization https://github.com/precice/micro-manager/pull/169
11
+
- Delete the simulation object when the simulation is deactivated https://github.com/precice/micro-manager/pull/167
12
+
- Remove float32 data type restriction for adaptivity data [commit](https://github.com/precice/micro-manager/commit/bfa44ff4d3432c6ac0f3b1311274308d2ec9c2a4)
13
+
- Trigger adaptivity when all the adaptivity data is the same https://github.com/precice/micro-manager/pull/170
14
+
- Add configuration option to control frequency of adaptivity computation https://github.com/precice/micro-manager/pull/168
15
+
- Remove checkpointing of adaptivity and fix output of memory usage https://github.com/precice/micro-manager/pull/166
16
+
- Performance improvements: restricting data types, in-place modifications https://github.com/precice/micro-manager/pull/162
17
+
- Handle adaptivity case when deactivation and activation happens in the same time window https://github.com/precice/micro-manager/pull/165
18
+
- Add command line input argument to set log file https://github.com/precice/micro-manager/pull/163
19
+
- Fix adaptivity metrics logging and add logging documentation https://github.com/precice/micro-manager/pull/160
20
+
- Checkpoint lazily created simulation only if a checkpoint is necessary https://github.com/precice/micro-manager/pull/161
21
+
3
22
## v0.6.0
4
23
5
24
- Add functionality for lazy creation and initialization of micro simulations https://github.com/precice/micro-manager/pull/117
A tool to facilitate solving two-scale (macro-micro) coupled problems using the coupling library [preCICE](https://precice.org/).
11
+
A tool to create and manage a large number of (micro) simulations and couple them to a (macro) simulation using the coupling library [preCICE](https://precice.org/).
14
12
15
13
The main documentation is rendered on the [preCICE website](https://precice.org/tooling-micro-manager-overview.html).
Copy file name to clipboardExpand all lines: docs/configuration.md
+25-15Lines changed: 25 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ summary: Provide a JSON file to configure the Micro Manager.
7
7
8
8
{% note %} In the preCICE XML configuration the Micro Manager is a participant with the name `Micro-Manager`. {% endnote %}
9
9
10
-
The Micro Manager is configured with a JSON file. An example configuration file is
10
+
The Micro Manager is configured with a JSON file. An example configuration file looks like
11
11
12
12
```json
13
13
{
@@ -23,16 +23,23 @@ The Micro Manager is configured with a JSON file. An example configuration file
23
23
"micro_dt": 1.0
24
24
},
25
25
"diagnostics": {
26
-
"output_micro_sim_solve_time": "True"
26
+
"output_micro_sim_solve_time": true
27
27
}
28
28
}
29
29
```
30
30
31
31
This example configuration file is in [`examples/micro-manager-config.json`](https://github.com/precice/micro-manager/tree/develop/examples/micro-manager-config.json).
32
32
33
-
The path to the file containing the Python importable micro simulation class is specified in the `micro_file_name` parameter. If the file is not in the working directory, give the relative path.
33
+
## Micro Manager Configuration
34
34
35
-
There are three main sections in the configuration file, the `coupling_params`, the `simulation_params` and the optional `diagnostics`.
35
+
Parameter | Description
36
+
--- | ---
37
+
`micro_file_name` | Path to the file containing the Python importable micro simulation class. If the file is not in the working directory, give the relative path from the directory where the Micro Manager is executed.
38
+
`output_directory` | Path to output directory for logging and performance metrics. Directory is created if not existing already.
39
+
`memory_usage_output_type` | Set to either `local`, `global`, or `all`. `local` outputs rank-wise peak memory usage. `global` outputs global averaged peak memory usage. `all` outputs both local and global levels. All output is to a CSV file with the peak memory usage (RSS) in every time window, in MBs.
40
+
`memory_usage_output_n` | Frequency of output of memory usage (integer which is number of time windows).
41
+
42
+
Apart from the base settings, there are three main sections in the configuration file, [coupling parameters](#coupling-parameters), [simulation parameters](#simulation-parameters), and [diagnostics](#diagnostics).
36
43
37
44
## Coupling Parameters
38
45
@@ -55,9 +62,9 @@ Adaptivity parameters | See section on [adaptivity](#adaptivity). By default, ad
55
62
## Diagnostics
56
63
57
64
Parameter | Description
58
-
--- | ---
65
+
--- | ---H
59
66
`data_from_micro_sims` | A Python dictionary with the names of the data from the micro simulation to be written to VTK files as keys and `"scalar"` or `"vector"` as values.
60
-
`output_micro_sim_solve_time` | If `True`, the Micro Manager writes the wall clock time of the `solve()` function of each micro simulation.
67
+
`output_micro_sim_solve_time` | If `true`, the Micro Manager writes the wall clock time of the `solve()` function of each micro simulation.
61
68
`micro_output_n`| Frequency of calling the optional output functionality of the micro simulation in terms of number of time steps. If not given, `micro_sim.output()` is called every time step.
62
69
63
70
### Adding diagnostics in the preCICE XML configuration
@@ -109,18 +116,21 @@ The Micro Manager can adaptively control micro simulations. The adaptivity strat
109
116
110
117
All the adaptivity parameters are chosen from the second publication.
111
118
112
-
To turn on adaptivity, set `"adaptivity": True` in `simulation_params`. Then under `adaptivity_settings` set the following variables:
119
+
To turn on adaptivity, set `"adaptivity": true` in `simulation_params`. Then under `adaptivity_settings` set the following variables:
113
120
114
121
Parameter | Description
115
122
--- | ---
116
123
`type` | Set to either `local` or `global`. The type of adaptivity matters when the Micro Manager is run in parallel. `local` means comparing micro simulations within a local partitioned domain for similarity. `global` means comparing micro simulations from all partitions, so over the entire domain.
117
124
`data` | List of names of data which are to be used to calculate if micro-simulations are similar or not. For example `["temperature", "porosity"]`.
125
+
`adaptivity_every_n_time_windows` | Frequency of adaptivity computation (integer which is number of time windows).
126
+
`output_type` | Set to either `local`, `global`, or `all`. `local` outputs rank-wise adaptivity metrics. `global` outputs global averaged metrics. `all` outputs both local and global metrics.
127
+
`output_n` | Frequency of output of adaptivity metrics (integer which is number of time windows).
118
128
`history_param` | History parameter $$ \Lambda $$, set as $$ \Lambda >= 0 $$.
119
129
`coarsening_constant` | Coarsening constant $$ C_c $$, set as $$ 0 =< C_c < 1 $$.
120
130
`refining_constant` | Refining constant $$ C_r $$, set as $$ 0 =< C_r < 1 $$.
121
-
`every_implicit_iteration` | If True, adaptivity is calculated in every implicit iteration. <br> If False, adaptivity is calculated once at the start of the time window and then reused in every implicit time iteration.
122
-
`similarity_measure`| Similarity measure to be used for adaptivity. Can be either `L1`, `L2`, `L1rel` or `L2rel`. By default, `L1` is used. The `rel` variants calculate the respective relative norms. This parameter is *optional*.
123
-
`lazy_initialization` | Set to `True` to lazily create and initialize micro simulations. If selected, micro simulation objects are created only when the micro simulation is activated for the first time. Default: `False`.
131
+
`every_implicit_iteration` | If `true`, adaptivity is calculated in every implicit iteration. <br> If False, adaptivity is calculated once at the start of the time window and then reused in every implicit time iteration. Default `false`.
132
+
`similarity_measure`| Similarity measure to be used for adaptivity. Can be either `L1`, `L2`, `L1rel` or `L2rel`. By default, `L1` is used. The `rel` variants calculate the respective relative norms. This parameter is *optional*. Default `L1`.
133
+
`lazy_initialization` | Set to `true` to lazily create and initialize micro simulations. If selected, micro simulation objects are created only when the micro simulation is activated for the first time. Default: `false`.
124
134
125
135
The primary tuning parameters for adaptivity are the history parameter $$ \Lambda $$, the coarsening constant $$ C_c $$, and the refining constant $$ C_r $$. Their effects can be interpreted as:
126
136
@@ -133,15 +143,15 @@ Example of adaptivity configuration is
133
143
```json
134
144
"simulation_params": {
135
145
"macro_domain_bounds": [0, 1, 0, 1, 0, 1],
136
-
"adaptivity": "True",
146
+
"adaptivity": true,
137
147
"adaptivity_settings" {
138
148
"type": "local",
139
149
"data": ["temperature", "porosity"],
140
150
"history_param": 0.5,
141
151
"coarsening_constant": 0.3,
142
152
"refining_constant": 0.4,
143
-
"every_implicit_iteration": "True",
144
-
"lazy_initialization": "True"
153
+
"every_implicit_iteration": true,
154
+
"lazy_initialization": true
145
155
}
146
156
}
147
157
```
@@ -175,9 +185,9 @@ The Micro Manager uses the output functionality of preCICE, hence these data set
175
185
## Interpolate a crashed micro simulation
176
186
177
187
If the optional dependency `sklearn` is installed, the Micro Manager will derive the output of a crashed micro simulation by interpolating outputs from similar simulations. To enable this, set
178
-
`"interpolate_crash": "True"` in the `simulation_params` section of the configuration file.
188
+
`"interpolate_crash": true` in the `simulation_params` section of the configuration file.
179
189
180
-
For more details on the interpolation see the [crash handling documentation](tooling-micro-manager-running.html/#what-happens-when-a-micro-simulation-crashes).
190
+
For more details on the interpolation see the [crash handling documentation](tooling-micro-manager-running.html#what-happens-when-a-micro-simulation-crashes).
Copy file name to clipboardExpand all lines: docs/installation.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,23 +7,25 @@ summary: Install the Micro Manager by running `pip install --user micro-manager-
7
7
8
8
## Get the latest Micro Manager release
9
9
10
-
The Micro Manager can be installed using `pip`. Make sure [preCICE](installation-overview.html) is installed before installing the Micro Manager. The Micro Manager is compatible with preCICE version [2.3.0](https://github.com/precice/precice/releases/tag/v2.3.0) and higher.
10
+
### Option 1: Install using pip
11
11
12
-
### Option 1: Install from PyPI
13
-
14
-
The Micro Manager package has the name [micro-manager-precice](https://pypi.org/project/micro-manager-precice/) on PyPI. To install `micro-manager-precice`, run
12
+
The Micro Manager package on PyPI is [micro-manager-precice](https://pypi.org/project/micro-manager-precice/). To install, run
15
13
16
14
```bash
17
-
pip install --user micro-manager-precice
15
+
pip install micro-manager-precice
18
16
```
19
17
20
-
Unless already installed, the dependencies will be installed by `pip` during the installation procedure. To enable [crash handling by interpolation](tooling-micro-manager-running.html/#what-happens-when-a-micro-simulation-crashes), the optional dependency `sklearn` is required. To install `micro-manager-precice`with `sklearn`, run
18
+
To enable [crash handling by interpolation](tooling-micro-manager-running.html/#what-happens-when-a-micro-simulation-crashes), the optional dependency sklearn is required. To install with sklearn, run
21
19
22
20
```bash
23
-
pip install --user micro-manager-precice[sklearn]
21
+
pip install micro-manager-precice[sklearn]
24
22
```
25
23
26
-
preCICE itself needs to be installed separately. If you encounter problems in the direct installation, see the [dependencies section](#required-dependencies) and [optional dependency section](#optional-dependencies) below.
24
+
To use the Micro Manager for [snapshot computation](tooling-micro-manager-snapshot-configuration.html), the optional dependency h5py is required. To install with h5py, run
25
+
26
+
```bash
27
+
pip install micro-manager-precice[snapshot]
28
+
```
27
29
28
30
### Option 2: Install manually
29
31
@@ -32,10 +34,10 @@ preCICE itself needs to be installed separately. If you encounter problems in th
32
34
Ensure that the following dependencies are installed:
33
35
34
36
* Python 3
35
-
*[preCICE](installation-overview.html)[v2.3.0](https://github.com/precice/precice/releases/tag/v2.3.0) or higher
36
37
*[pyprecice: Python language bindings for preCICE](installation-bindings-python.html)
summary: The Micro Manager logs relevant information and adaptivity metrics.
6
+
---
7
+
8
+
The Micro Manager uses the Python [logging](https://docs.python.org/3/library/logging.html) functionality. The format is:
9
+
10
+
```bash
11
+
(<rank>) <date and time><part/functionality of Micro Manager><log level><message>
12
+
```
13
+
14
+
For example
15
+
16
+
```bash
17
+
(0) 04/17/2025 02:54:02 PM - micro_manager.micro_manager - INFO - Time window 1 converged.
18
+
```
19
+
20
+
The information (`INFO` level) message `Time window 1 converged.` from the file `micro_manager/micro_manager.py` is logged by rank `0` at `02:54:02 PM` on `04/17/2025`.
21
+
22
+
## Parsing log output
23
+
24
+
By default, the Micro Manager parses the log output to the terminal (`sys.out`). A log file, for example `micro-manager.log`, can be passed as a command line input in the following way
If the Micro Manager is run with adaptivity, rank-wise and global metrics are written to CSV files. By default, the files are created in the working directory. To create the files in a specific folder, provide the folder path via the configuration parameter `output_dir`. More information is in the [configuration section](tooling-micro-manager-configuration.html).
33
+
34
+
The following global metrics are logged to the file `adaptivity-metrics-global.csv`:
35
+
36
+
- Time window at which the metrics are logged
37
+
- Average number of active simulations
38
+
- Average number of inactive simulations
39
+
- Maximum number of active simulations
40
+
- Maximum number of inactive simulations
41
+
42
+
The CSV file heading is `n,avg active,avg inactive,max active,max inactive`.
43
+
44
+
The following local metrics are logged to the file `adaptivity-metrics-`rank`.csv`:
45
+
46
+
for local adaptivity:
47
+
48
+
- Time window at which the metrics are logged
49
+
- Number of active simulations
50
+
- Number of inactive simulations
51
+
52
+
The CSV file heading is `n,n active,n inactive`.
53
+
54
+
for global adaptivity:
55
+
56
+
- Time window at which the metrics are logged
57
+
- Number of active simulations
58
+
- Number of inactive simulations
59
+
- Ranks to which inactive simulations on this rank are associated
60
+
61
+
The CSV file heading is `n,n active,n inactive,assoc ranks`.
62
+
63
+
To set the output interval of adaptivity metrics, set `output_n` in the [adaptivity configuration](tooling-micro-manager-configuration.html#adaptivity).
Copy file name to clipboardExpand all lines: docs/micro-simulation-convert-to-library.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,6 +97,11 @@ The `solve()` function should have the following signature:
97
97
This will create a shared library `micro_dummy.so` which can be directly imported in Python.
98
98
For more information on compiling C++ libraries, see the [pybind11 documentation](https://pybind11.readthedocs.io/en/stable/compiling.html).
99
99
100
+
There are more examples which demonstrate how a micro simulation written in C++ is converted to a Python-importable class
101
+
102
+
1. [DuMuX-based micro simulation](https://github.com/precice/tutorials/blob/v202404.0/two-scale-heat-conduction/micro-dumux/appl/micro_sim.cpp) in the two-scale heat conduction tutorial.
Micro simulations can be initialized before the actual coupling starts. To initialize a micro simulation, define an `initialize()`functionin the code. The Micro Manager calls the initialize functionfor every micro simulation. If the macro simulation writes initial data to preCICE, the Micro Manager attempts to pass it to the micro simulation. If the `initialize()`functiondoes not have input parameters, the initial data will not be passed. The `initialize()`functioncanreturn data to the Micro Manager. This data is only relevant to compute the adaptivity before the coupling starts. Therefore, if the `initialize()` functions returns data, it must be the data expected by the adaptivity.
0 commit comments