Skip to content

Commit bb89e91

Browse files
committed
Cosmetic changes to documentation.
1 parent 3bc6a05 commit bb89e91

File tree

3 files changed

+70
-75
lines changed

3 files changed

+70
-75
lines changed

docs/demonstrations.md

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Demonstrations
22

3-
## Busbar
3+
## Busbar example
44

55
["Electrical Heating in a Busbar"][busbar] is an example model featured
66
in the tutorial of ["Introduction to Comsol Multiphysics"][intro] and
@@ -29,7 +29,7 @@ Tmax = 330.42 K at (0.105000, -0.024899, 0.053425)
2929
Tmin = 322.41 K at (0.063272, 0.000000, 0.000000)
3030
```
3131

32-
You could now sweep the model's parameters, for example the length `L`
32+
We could now sweep the model's parameters, for example the length `L`
3333
or width `wbb` of the busbar.
3434

3535

@@ -56,10 +56,9 @@ for file in Path.cwd().glob('*.mph'):
5656
model.save()
5757
```
5858

59-
The script [`compact_models.py`][compact] in the [`demos`][demos] folder
60-
of the source-code [repository][repo] is a refined version of the above
61-
code. It displays more status information and also resets the modeling
62-
history.
59+
The script [`compact_models.py`][compact] in the `demos` folder of the
60+
source-code repository is a refined version of the above code. It
61+
displays more status information and also resets the modeling history.
6362

6463
Note that we could easily go through all sub-directories recursively
6564
by replacing [`glob`](python:pathlib.Path.glob) with
@@ -178,11 +177,11 @@ it is we do with simulation results.
178177

179178
The complete script [`worker_pool.py`][pool], which implements all of
180179
the above and also irons out some wrinkles not covered here for the
181-
sake of brevity, can be found in the [`demos`][demos] folder of the
182-
source-code [repository][repo]. As it runs, it displays a live plot
183-
such as the one that follows. It is reproduced here preserving the real
184-
time from a run with two workers. Observe how the first two data points
185-
do in fact come in out of order.
180+
sake of brevity, can be found in the `demos` folder of the source-code
181+
repository. As it runs, it displays a live plot such as the one that
182+
follows. It is reproduced here preserving the real time from a run with
183+
two workers. Observe how the first two data points do in fact come in
184+
out of order.
186185

187186
```{image} images/worker_pool.gif
188187
:alt: Live plot of worker pool demo
@@ -297,10 +296,10 @@ Java, or Matlab project.
297296

298297
Comsol can be very helpful in creating the Java code corresponding to
299298
changes we make to a model. Not only does the GUI provide a function to
300-
"copy as code to clipboard" on any node, it also let's us save the
301-
entire model as Java source code. And if we "compact the history" right
302-
before making changes, the new code can conveniently be found at the
303-
very end of the Java file.
299+
"copy as code to clipboard" on any node, it also lets us save the entire
300+
model as Java source code. And if we "compact the history" right before
301+
making changes, the new code can conveniently be found at the very end
302+
of the Java file.
304303

305304

306305
## Navigate and alter the model
@@ -339,11 +338,11 @@ creates that node in its parent group, here the built-in group
339338

340339
So far, we have used strings to refer to nodes. We could also use the
341340
[`Node`](mph.Node) class, which offers more flexibility and extra
342-
functionality. Instances of that class are returned by
343-
[`model.create()`](mph.Model) for convenience. But they can be
344-
generated from scratch by string concatenation with the division
345-
operator — much like [`pathlib.Path`](python:pathlib.Path) objects
346-
from Python's standard library.
341+
functionality. Instances of that class are returned by `model.create()`
342+
for convenience. But they can be generated from scratch by string
343+
concatenation with the division operator — much like
344+
[`pathlib.Path`](python:pathlib.Path) objects from Python's standard
345+
library.
347346
```python
348347
import mph
349348
client = mph.start()
@@ -424,8 +423,6 @@ more advanced features than in the simple example here: It generates
424423
the demonstration model used in the [Tutorial](tutorial).
425424

426425

427-
[repo]: https://github.com/MPh-py/MPh
428-
[demos]: https://github.com/MPh-py/MPh/tree/main/demos
429426
[capa]: https://github.com/MPh-py/MPh/blob/main/demos/capacitor.mph
430427
[compact]: https://github.com/MPh-py/MPh/blob/main/demos/compact_models.py
431428
[pool]: https://github.com/MPh-py/MPh/blob/main/demos/worker_pool.py

docs/limitations.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,24 @@
33
## Java bridge
44

55
MPh is built on top of the Python-to-Java bridge [JPype][jpype]. It is
6-
JPype that allows us to look at [Comsol's Java API][japi] and run the
7-
same commands from Python. All credit to the JPype developers for making
8-
this possible.
9-
10-
The Comsol API does not support running more than one client at a time,
11-
i.e. within the same Java program. Meanwhile, JPype cannot manage more
12-
than one Java virtual machine within the same Python process. If it
13-
could, it would be easy to work around Comsol's limitation. (There is
14-
an alternative Java bridge, [pyJNIus][jnius], which is not limited to
15-
one virtual machine, but then fails in another regard: A number of Java
16-
methods exposed by Comsol are inexplicably missing from the Python
6+
JPype that allows us to look at Comsol's [Programming Manual][manual]
7+
or its [API reference][api] and run the same commands from Python. All
8+
credit to the JPype developers for making this possible.
9+
10+
Unfortunately, the Comsol API does not support running more than one
11+
client at a time, i.e. within the same Java program. Meanwhile, JPype
12+
cannot manage more than one Java virtual machine within the same Python
13+
process. If it could, it would be easy to work around Comsol's limitation.
14+
(There is an alternative Java bridge, [pyJNIus][jnius], which is not
15+
limited to one virtual machine, but then fails in another regard: A number
16+
of Java methods exposed by Comsol are inexplicably missing from the Python
1717
encapsulation.)
1818

1919
Therefore, if several simulations are to be run in parallel, distributed
2020
over independent processor cores in an effort to achieve maximum speed-up
2121
of a parameter sweep, they have to be started as separate Python
22-
subprocesses. Refer to section
23-
["Multiple processes"](demonstrations.md#multiple-processes) for a
24-
demonstration.
22+
subprocesses. Refer to section ["Multiple
23+
processes"](demonstrations.md#multiple-processes) for a demonstration.
2524

2625
Additionally, there are some known, but unresolved issues with JPype's
2726
shutdown of the Java virtual machine. Notably, pressing <kbd>Ctrl+C</kbd>
@@ -32,29 +31,28 @@ exceptions in application code.
3231

3332
## Platform differences
3433

35-
The [Comsol API][japi] offers two distinct ways to run a simulation
36-
session on the local machine. One may either start a "stand-alone"
37-
client, which does not require a Comsol server. Or one may start a
38-
server separately and have a "thin" client connect to it via a
39-
loop-back network socket. The first approach is more lightweight and
40-
more reliable, as it keeps everything inside the same process. The
41-
second approach is slower to start up and relies on the inter-process
42-
communication to be robust, but would also work across the network,
43-
i.e., for remote sessions where the client runs locally and delegates
44-
the heavy lifting to a server running on another machine. If we
45-
instantiate the [`Client`](mph.Client) class without providing a
46-
value for the host address and network port, it will create a
47-
stand-alone client. Otherwise it will run in client–server mode.
48-
49-
On Linux and macOS however, the stand-alone mode does not work out of
34+
The Comsol API offers two distinct ways to run a simulation session on
35+
the local machine. We can either start a "stand-alone" client, which
36+
does not require a Comsol server. Or we first start a server and then
37+
have a "thin" client connect to it via a loop-back network socket. The
38+
first approach is more lightweight and more reliable, as it keeps
39+
everything inside the same process. The second approach is slower to
40+
start up and relies on the inter-process communication to be robust,
41+
but would also work across the network, i.e., for remote sessions where
42+
the client runs locally and delegates the heavy lifting to a server
43+
running on another machine. If we instantiate the [`Client`](mph.Client)
44+
class without providing a value for the network port, it will create a
45+
stand-alone client. Otherwise it will run as a thin client in
46+
client–server mode.
47+
48+
On Linux and macOS, however, the stand-alone mode does not work out of
5049
the box. This is due to a limitation of Unix-like operating systems
5150
and explained in more detail in [GitHub issue #8][issue8]. On these
5251
platforms, if all you did was install MPh, starting the client in
53-
stand-alone mode will raise a `java.lang.UnsatisfiedLinkError`
54-
because required external libraries cannot be found. You would have
55-
to add the full paths of shared-library folders to an environment
56-
variable named `LD_LIBRARY_PATH` on Linux and `DYLD_LIBRARY_PATH` on
57-
macOS.
52+
stand-alone mode will raise a `java.lang.UnsatisfiedLinkError` because
53+
required external libraries cannot be found. You would have to add the
54+
full paths of certain shared-library folders to an environment variable
55+
named `LD_LIBRARY_PATH` on Linux and `DYLD_LIBRARY_PATH` on macOS.
5856

5957
For example, for an installation of Comsol 5.6 on Ubuntu Linux, you
6058
would add the following lines at the end of the shell configuration
@@ -69,16 +67,18 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH\
6967
```
7068

7169
On macOS, the root folder is `/Applications/COMSOL56/Multiphysics`.
72-
The folder names in this example depend on the installed Comsol version
73-
and will have to be adapted accordingly.
74-
75-
Requiring this variable to be set correctly limits the possibility of
76-
selecting a specific Comsol version from within MPh, as adding multiple
77-
installations to that search path will lead to name collisions. One
78-
could work around the issue by wrapping a Python program using MPh in
79-
a shell script that sets the environment variable only for that one
80-
process. Or have the Python program run the Comsol session in another
81-
Python subprocess. However, none of this is ideal. Starting the client
70+
The folder names depend on the installed Comsol version and will have
71+
to be adapted accordingly.
72+
73+
Requiring the environment variable to be set correctly limits the
74+
possibility of selecting a specific Comsol version from within MPh,
75+
as adding multiple installations to that search path will lead to name
76+
collisions. One could work around the issue by wrapping a Python program
77+
using MPh in a shell script that sets the environment variable before
78+
starting the Python process. That's effectively what Comsol itself does
79+
to launch its GUI on one of these platforms. Or we could have a Python
80+
program that sets the environment variable and then runs MPh in a second
81+
Python subprocess. Clearly, none of this is ideal. Starting the client
8282
should work without any of these detours.
8383

8484
The function [`mph.start()`](mph.start) exists to navigate these
@@ -89,8 +89,7 @@ shell configuration is required up front. This behavior is reflected
8989
in the configuration option `'session'`, accessible via
9090
[`mph.option()`](mph.config), which is set to `'platform-dependent'`
9191
by default. It could also be set to `'stand-alone'` or `'client-server'`
92-
before calling [`start()`](mph.start) in order to override the
93-
default behavior.
92+
before calling `start()` in order to override the default behavior.
9493

9594
Performance in client–server mode is noticeably worse in certain
9695
scenarios, not just at start-up. If functions access the Java API
@@ -106,6 +105,7 @@ where this works reliably.
106105

107106

108107
[jpype]: https://github.com/jpype-project/jpype
109-
[japi]: https://comsol.com/documentation/COMSOL_ProgrammingReferenceManual.pdf
108+
[manual]: https://comsol.com/documentation/COMSOL_ProgrammingReferenceManual.pdf
109+
[api]: https://doc.comsol.com/5.6/doc/com.comsol.help.comsol/api
110110
[jnius]: https://pyjnius.readthedocs.io
111111
[issue8]: https://github.com/MPh-py/MPh/issues/8

docs/releases.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@
113113

114114
## 0.8.2
115115
* [Published](https://pypi.org/project/MPh/0.8.2) on February 13, 2021.
116-
* Works around issue of [incorrect exit behavior](https://github.com/MPh-py/MPh/issues/15).
117-
* Fixes: Exit code was always 0, even when terminating with `sys.exit(2)`.
118-
* Fixes: Exit code was 0, not 1, when exiting due to unhandled exception.
116+
* Fixes: Exit code was always 0, even when terminating with `sys.exit(2)`. ([#15](https://github.com/MPh-py/MPh/issues/15))
117+
* Fixes: Exit code was 0, not 1, when exiting due to unhandled exception. ([#15](https://github.com/MPh-py/MPh/issues/15))
119118

120119
## 0.8.1
121120
* [Published](https://pypi.org/project/MPh/0.8.1) on February 9, 2021.
@@ -144,7 +143,6 @@
144143
* Performs a regular shutdown of the Java VM, as opposed to releases to follow.
145144
* Respects user-set Comsol preferences when starting [`Client`](https://mph.readthedocs.io/en/0.7/api/mph.Client.html).
146145
* Adds screen-shot of Comsol demonstration model to [Tutorial](https://mph.readthedocs.io/en/0.7/tutorial.html).
147-
* Adds [deployment](https://github.com/MPh-py/MPh/tree/a86f77a7b26e24e314c01639b846a3ee927f1e6d/deploy) instructions for developers.
148146

149147
## 0.7.4
150148
* [Published](https://pypi.org/project/MPh/0.7.4) on July 17, 2020.
@@ -165,8 +163,8 @@
165163

166164
## 0.7.1
167165
* [Published](https://pypi.org/project/MPh/0.7.1) on May 17, 2020… later that day.
168-
* Fixes meta information [on PyPI](https://pypi.org/project/MPh).
166+
* Fixes meta information on PyPI.
169167

170168
## 0.7.0
171169
* [Published](https://pypi.org/project/MPh/0.7.0) on May 17, 2020.
172-
* First open-source release [published on PyPI](https://pypi.org/project/MPh#history).
170+
* First open-source release published on PyPI.

0 commit comments

Comments
 (0)