Skip to content

Commit

Permalink
REFACTOR
Browse files Browse the repository at this point in the history
  • Loading branch information
shredEngineer committed Jan 3, 2022
1 parent 07bd443 commit 4a806c8
Show file tree
Hide file tree
Showing 188 changed files with 3,988 additions and 2,000 deletions.
2 changes: 1 addition & 1 deletion MagnetiCalc-DefaultProject.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[DEFAULT]
version = MagnetiCalc v1.12.0
version = MagnetiCalc v1.12.1
backend_type = 1
auto_calculation = True
num_cores = 0
Expand Down
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,14 @@ Installation will currently fail for Python 3.9+ due to missing dependencies.

On some systems, it may be necessary to install the latest [Microsoft Visual C++ Redistributable](https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170) first.

#### macOS
#### macOS with Apple Silicon (M1)
On Apple Silicon, make sure to enable [Open Using Rosetta](https://www.courier.com/blog/tips-and-tricks-to-setup-your-apple-m1-for-development/) for the Terminal app
before installing and starting MagnetiCalc.

*Note:* Might be unstable.

### Option A: Automatic install via pip
This will install or upgrade MagnetiCalc (and its dependencies) to the user site-packages directory and start it from there.

#### Linux & macOS
#### Linux & macOS (Intel)
```shell
python3 -m pip install magneticalc --upgrade
python3 -m magneticalc
Expand All @@ -146,6 +144,13 @@ python -m pip install --upgrade magneticalc
python -m magneticalc
```

#### macOS with Apple Silicon (M1)
*Note:* On Apple Silicon, JIT must be disabled due to incomplete support, resulting in slow calculations.
```shell
python3 -m pip install magneticalc --upgrade
export NUMBA_DISABLE_JIT=1 && python3 -m magneticalc
```

#### Juptyer Notebook & Jupyter Lab
From within a [Jupyter](https://jupyter.org/) Notebook,
MagnetiCalc can be installed (upgraded) and run like this:
Expand Down Expand Up @@ -229,14 +234,24 @@ provides basic functions for importing/exporting data programmatically:

The data is wrapped in a [`MagnetiCalc_Data`](magneticalc/MagnetiCalc_Data.py) object
which provides convenience functions for accessing, transforming and reshaping the data:
* `.get_wire_list()` returns a list of all 3D points of the wire.
* `.get_wire()` returns the raveled wire points as three arrays.
* `.get_current()` returns the wire current.
* `.get_dimension()` returns the sampling volume dimension as a 3-tuple.
* `.get_axes(reduce=True)` returns the axis ticks of the sampling volume.
* `.get_axes_list()` returns a list of all 3D points of the sampling volume.
* `.get_axes()` returns the raveled sampling volume coordinates as three arrays.
* `.get_axes(reduce=True)` returns the axis ticks of the sampling volume.
* `.get_a_field_list()` returns a list of all 3D vectors of the
<img src="https://render.githubusercontent.com/render/math?math=\mathbf{A}" alt="A">-Field.
<img src="https://render.githubusercontent.com/render/math?math=\mathbf{A}" alt="A">-field.
* `.get_a_field()` returns the raveled
<img src="https://render.githubusercontent.com/render/math?math=\mathbf{A}" alt="A">-field
coordinates as three arrays.
* `.get_a_field(as_3d=True)` returns a 3D field for each component of the
<img src="https://render.githubusercontent.com/render/math?math=\mathbf{A}" alt="A">-Field,
<img src="https://render.githubusercontent.com/render/math?math=\mathbf{A}" alt="A">-field,
indexed over the reduced axes.

Analogously, use the `.get_b_field_list()` and `.get_b_field()` functions
to get the <img src="https://render.githubusercontent.com/render/math?math=\mathbf{B}" alt="B">-field.

License
-------
Expand Down Expand Up @@ -295,11 +310,8 @@ ToDo
* Fix unnecessary shading of VisPy markers.

**Code Quality**
* Add debug output where it is missing.
* Add type hints where they are missing.
* Add unit tests.
* Use the [`@property` decorator](https://stackoverflow.com/a/36943813/2035671) for accessing data where applicable.
* Merge sparse `*_Types.py` modules with higher-level classes if possible.

**Design**
* Replace plain `QMessageBox` dialogs with nice-looking custom dialogs where possible.
Expand Down
Binary file removed docs/Screenshot.png
Binary file not shown.
Binary file removed docs/Video-Thumb.png
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/classIndex.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h2>
<p>
This documentation was automatically generated by
<a href="https://github.com/twisted/pydoctor/">pydoctor</a>
at 2022-01-02 09:06:24.
at 2022-01-03 23:22:21.
</p>

</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/magneticalc.API.API.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ <h1 class="class"><code>magneticalc.API.API</code> <small>class documentation</s

</div>
<address>
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-02 09:06:24.
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-03 23:22:21.
</address>

</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/magneticalc.API.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h1 class="module"><code>magneticalc.API</code> <small>module documentation</sma

</div>
<address>
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-02 09:06:24.
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-03 23:22:21.
</address>

</div>
Expand Down
14 changes: 7 additions & 7 deletions docs/magneticalc.About_Dialog.About_Dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,7 @@ <h1 class="class"><code>magneticalc.About_Dialog.About_Dialog(<a href="magnetica
</p>
<table class="children sortable" id="id7">

<tr class="baseinstancevariable">

<td>Instance Variable</td>
<td><a href="magneticalc.QLayouted.QLayouted.html#layout" class="code" data-type="Instance Variable">layout</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="basemethod">
<tr class="basemethod">

<td>Method</td>
<td><a href="magneticalc.QLayouted.QLayouted.html#install_layout" class="code" data-type="Method">install_layout</a></td>
Expand All @@ -129,6 +124,11 @@ <h1 class="class"><code>magneticalc.About_Dialog.About_Dialog(<a href="magnetica
<td>Method</td>
<td><a href="magneticalc.QLayouted.QLayouted.html#addButtons" class="code" data-type="Method">addButtons</a></td>
<td><span>Adds buttons.</span></td>
</tr><tr class="baseinstancevariable private">

<td>Instance Variable</td>
<td><a href="magneticalc.QLayouted.QLayouted.html#_layout" class="code" data-type="Instance Variable">_layout</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr>
</table>

Expand Down Expand Up @@ -193,7 +193,7 @@ <h1 class="class"><code>magneticalc.About_Dialog.About_Dialog(<a href="magnetica

</div>
<address>
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-02 09:06:24.
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-03 23:22:21.
</address>

</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/magneticalc.About_Dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h1 class="module"><code>magneticalc.About_Dialog</code> <small>module documenta

</div>
<address>
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-02 09:06:24.
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-03 23:22:21.
</address>

</div>
Expand Down
56 changes: 7 additions & 49 deletions docs/magneticalc.Assert_Dialog.Assert_Dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,10 @@ <h1 class="class"><code>magneticalc.Assert_Dialog.Assert_Dialog</code> <small>cl
<td>Method</td>
<td><a href="magneticalc.Assert_Dialog.Assert_Dialog.html#__init__" class="code" data-type="Method">__init__</a></td>
<td><span>Shows a user dialog if an assertion failed. Intended for beta-testing. This allows the user to either quit or resume (possibly resulting in unstable behaviour). Furthermore, it provides a link for filing an issue on GitHub (partially pre-filled).</span></td>
</tr><tr class="instancevariable">
</tr><tr class="instancevariable private">

<td>Instance Variable</td>
<td><a href="magneticalc.Assert_Dialog.Assert_Dialog.html#assertion" class="code" data-type="Instance Variable">assertion</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="instancevariable">

<td>Instance Variable</td>
<td><a href="magneticalc.Assert_Dialog.Assert_Dialog.html#message" class="code" data-type="Instance Variable">message</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="instancevariable">

<td>Instance Variable</td>
<td><a href="magneticalc.Assert_Dialog.Assert_Dialog.html#dialog" class="code" data-type="Instance Variable">dialog</a></td>
<td><a href="magneticalc.Assert_Dialog.Assert_Dialog.html#_dialog" class="code" data-type="Instance Variable">_dialog</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr>
</table>
Expand Down Expand Up @@ -96,48 +86,16 @@ <h1 class="class"><code>magneticalc.Assert_Dialog.Assert_Dialog</code> <small>cl

<div><p>Shows a user dialog if an assertion failed. Intended for beta-testing. This allows the user to either quit or resume (possibly resulting in unstable behaviour). Furthermore, it provides a link for filing an issue on GitHub (partially pre-filled).</p><table class="fieldTable"><tr class="fieldStart"><td class="fieldName">Parameters</td><td class="fieldArg">assertion</td><td>Boolean</td></tr><tr><td></td><td class="fieldArg">message</td><td>Error message</td></tr></table></div>
</div>
</div><div class="baseinstancevariable">

<a name="magneticalc.Assert_Dialog.Assert_Dialog.assertion">

</a>
<a name="assertion">

</a>
<div class="functionHeader">
assertion =

</div>
<div class="functionBody">

<div class="undocumented">Undocumented</div>
</div>
</div><div class="baseinstancevariable">

<a name="magneticalc.Assert_Dialog.Assert_Dialog.message">

</a>
<a name="message">

</a>
<div class="functionHeader">
message =

</div>
<div class="functionBody">

<div class="undocumented">Undocumented</div>
</div>
</div><div class="baseinstancevariable">
</div><div class="baseinstancevariable private">

<a name="magneticalc.Assert_Dialog.Assert_Dialog.dialog">
<a name="magneticalc.Assert_Dialog.Assert_Dialog._dialog">

</a>
<a name="dialog">
<a name="_dialog">

</a>
<div class="functionHeader">
dialog =
_dialog =

</div>
<div class="functionBody">
Expand All @@ -148,7 +106,7 @@ <h1 class="class"><code>magneticalc.Assert_Dialog.Assert_Dialog</code> <small>cl

</div>
<address>
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-02 09:06:24.
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-03 23:22:21.
</address>

</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/magneticalc.Assert_Dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h1 class="module"><code>magneticalc.Assert_Dialog</code> <small>module document

</div>
<address>
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-02 09:06:24.
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-03 23:22:21.
</address>

</div>
Expand Down
20 changes: 10 additions & 10 deletions docs/magneticalc.Backend_CUDA.Backend_CUDA.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ <h1 class="class"><code>magneticalc.Backend_CUDA.Backend_CUDA</code> <small>clas
<td>Method</td>
<td><a href="magneticalc.Backend_CUDA.Backend_CUDA.html#__init__" class="code" data-type="Method">__init__</a></td>
<td><span>Initializes the class attributes.</span></td>
</tr><tr class="instancevariable">

<td>Instance Variable</td>
<td><a href="magneticalc.Backend_CUDA.Backend_CUDA.html#field_type" class="code" data-type="Instance Variable">field_type</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="staticmethod">

<td>Static Method</td>
Expand All @@ -75,6 +70,11 @@ <h1 class="class"><code>magneticalc.Backend_CUDA.Backend_CUDA</code> <small>clas
<td><span>Calculates the field at every point of the sampling volume.</span></td>
</tr><tr class="instancevariable private">

<td>Instance Variable</td>
<td><a href="magneticalc.Backend_CUDA.Backend_CUDA.html#_field_type" class="code" data-type="Instance Variable">_field_type</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="instancevariable private">

<td>Instance Variable</td>
<td><a href="magneticalc.Backend_CUDA.Backend_CUDA.html#_distance_limit" class="code" data-type="Instance Variable">_distance_limit</a></td>
<td><span class="undocumented">Undocumented</span></td>
Expand Down Expand Up @@ -136,16 +136,16 @@ <h1 class="class"><code>magneticalc.Backend_CUDA.Backend_CUDA</code> <small>clas

<div><p>Initializes the class attributes.</p><table class="fieldTable"><tr class="fieldStart"><td class="fieldName">Parameters</td><td class="fieldArg">field_type</td><td>Field type</td></tr><tr><td></td><td class="fieldArg">distance_limit</td><td>Distance limit (mitigating divisions by zero)</td></tr><tr><td></td><td class="fieldArg">length_scale</td><td>Length scale (m)</td></tr><tr><td></td><td class="fieldArg">dc</td><td>Wire current (A)</td></tr><tr><td></td><td class="fieldArg">current_elements</td><td>Ordered list of current elements (pairs: [element center, element direction])</td></tr><tr><td></td><td class="fieldArg">sampling_volume_points</td><td>Ordered list of sampling volume points</td></tr><tr><td></td><td class="fieldArg">sampling_volume_permeabilities</td><td>Ordered list of sampling volume's relative permeabilities µ_r</td></tr><tr><td></td><td class="fieldArg">progress_callback</td><td>Progress callback</td></tr></table></div>
</div>
</div><div class="baseinstancevariable">
</div><div class="baseinstancevariable private">

<a name="magneticalc.Backend_CUDA.Backend_CUDA.field_type">
<a name="magneticalc.Backend_CUDA.Backend_CUDA._field_type">

</a>
<a name="field_type">
<a name="_field_type">

</a>
<div class="functionHeader">
field_type =
_field_type =

</div>
<div class="functionBody">
Expand Down Expand Up @@ -325,7 +325,7 @@ <h1 class="class"><code>magneticalc.Backend_CUDA.Backend_CUDA</code> <small>clas

</div>
<address>
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-02 09:06:24.
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-03 23:22:21.
</address>

</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/magneticalc.Backend_CUDA.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h1 class="module"><code>magneticalc.Backend_CUDA</code> <small>module documenta

</div>
<address>
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-02 09:06:24.
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-03 23:22:21.
</address>

</div>
Expand Down
22 changes: 11 additions & 11 deletions docs/magneticalc.Backend_JIT.Backend_JIT.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ <h1 class="class"><code>magneticalc.Backend_JIT.Backend_JIT</code> <small>class
<td>Method</td>
<td><a href="magneticalc.Backend_JIT.Backend_JIT.html#__init__" class="code" data-type="Method">__init__</a></td>
<td><span>Initializes the class attributes.</span></td>
</tr><tr class="instancevariable">

<td>Instance Variable</td>
<td><a href="magneticalc.Backend_JIT.Backend_JIT.html#field_type" class="code" data-type="Instance Variable">field_type</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="staticmethod">

<td>Static Method</td>
Expand All @@ -70,6 +65,11 @@ <h1 class="class"><code>magneticalc.Backend_JIT.Backend_JIT</code> <small>class
<td><span>Calculates the field at every point of the sampling volume.</span></td>
</tr><tr class="instancevariable private">

<td>Instance Variable</td>
<td><a href="magneticalc.Backend_JIT.Backend_JIT.html#_field_type" class="code" data-type="Instance Variable">_field_type</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="instancevariable private">

<td>Instance Variable</td>
<td><a href="magneticalc.Backend_JIT.Backend_JIT.html#_distance_limit" class="code" data-type="Instance Variable">_distance_limit</a></td>
<td><span class="undocumented">Undocumented</span></td>
Expand Down Expand Up @@ -131,16 +131,16 @@ <h1 class="class"><code>magneticalc.Backend_JIT.Backend_JIT</code> <small>class

<div><p>Initializes the class attributes.</p><table class="fieldTable"><tr class="fieldStart"><td class="fieldName">Parameters</td><td class="fieldArg">field_type</td><td>Field type</td></tr><tr><td></td><td class="fieldArg">distance_limit</td><td>Distance limit (mitigating divisions by zero)</td></tr><tr><td></td><td class="fieldArg">length_scale</td><td>Length scale (m)</td></tr><tr><td></td><td class="fieldArg">dc</td><td>Wire current (A)</td></tr><tr><td></td><td class="fieldArg">current_elements</td><td>Ordered list of current elements (pairs: [element center, element direction])</td></tr><tr><td></td><td class="fieldArg">sampling_volume_points</td><td>Ordered list of sampling volume points</td></tr><tr><td></td><td class="fieldArg">sampling_volume_permeabilities</td><td>Ordered list of sampling volume's relative permeabilities µ_r</td></tr><tr><td></td><td class="fieldArg">progress_callback</td><td>Progress callback</td></tr></table></div>
</div>
</div><div class="baseinstancevariable">
</div><div class="baseinstancevariable private">

<a name="magneticalc.Backend_JIT.Backend_JIT.field_type">
<a name="magneticalc.Backend_JIT.Backend_JIT._field_type">

</a>
<a name="field_type">
<a name="_field_type">

</a>
<div class="functionHeader">
field_type =
_field_type =

</div>
<div class="functionBody">
Expand Down Expand Up @@ -268,7 +268,7 @@ <h1 class="class"><code>magneticalc.Backend_JIT.Backend_JIT</code> <small>class

</a>
<div class="functionHeader">
@staticmethod<br />@jit(nopython=True, parallel=True)<br />
@staticmethod<br />@ConditionalDecorator(get_jit_enabled(), jit, nopython=True, parallel=True)<br />
def
worker(field_type, distance_limit, length_scale, current_elements, sampling_volume_point):

Expand Down Expand Up @@ -301,7 +301,7 @@ <h1 class="class"><code>magneticalc.Backend_JIT.Backend_JIT</code> <small>class

</div>
<address>
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-02 09:06:24.
<a href="index.html">API Documentation</a> for <a href="https://github.com/shredEngineer/MagnetiCalc">MagnetiCalc</a>, generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> at 2022-01-03 23:22:21.
</address>

</div>
Expand Down
Loading

0 comments on commit 4a806c8

Please sign in to comment.