Giter Club home page Giter Club logo

magneticalc's People

Contributors

cschisholm avatar shredengineer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

magneticalc's Issues

[feature] allow calculating or visualizing field in an arbitrary plane only

I would like to be able to visualize the field in one specific plane only, currently I cannot find any way to do this.

Example:

I have a complicated wire loop located flat on the XY plane. A real world example would be for example the boundary wire of a robot lawn mower.

Now I want to visualize what the sensor in the mower is actually seeing, the sensor is always located in a plane of maybe 7 centimeters above the wire loop (or even more if the wire is buried below the surface).

For simulating this I would want to design the wire loop in plane XY and then I would need some way to specify another arbitrary plane (in my case the plane 7cm above the ground) and plot the field only in this plane.

Bonus-killer-feature: It would highlight with colors the points in this plane where the field vector is parallel to that plane because this would be where the mower would think the wire is located. Maybe some kind of heat map where the color depends on the Z-component of the vector (or any other parameter of the field to make it more universal) and then be able to export this 2d heat map as an image. This would be extremely useful.

TypeError: setValue(self, int): argument 1 has unexpected type 'float'

bernd@bernd-privat:~/MagnetiCalc$ git describe --tags
v1.15.1-1-g19b6897
bernd@bernd-privat:~/MagnetiCalc$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:        22.04
Codename:       jammy

This is what happens when I try to start it:

bernd@bernd-privat:~/MagnetiCalc$ python3 -m magneticalc

MagnetiCalc v1.15.1
Copyright © 2020–2022, Paul Wilhelm, M. Sc. <mailto:[email protected]>
ISC License (see README.md)

Performance Options: JIT Enabled, CUDA Not Available

main/__init__/Project.open_default()
main/__init__/open_default/Project.load(): Loading defaults
main/__init__/open_default/Project.load(): Creating empty User section
main/__init__/open_default/GUI.validate()
main/__init__/open_default/GUI.validate(): WARNING: Selected backend not available, using default backend
main/__init__/__init__/__init__/Model.set_parameters()
main/__init__/__init__/__init__/set_parameters/__exit__/Statusbar.invalidate()
main/__init__/__init__/__init__/set_parameters/__exit__/invalidate/Statusbar: Pending Calculation
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/bernd/MagnetiCalc/magneticalc/__main__.py", line 57, in <module>
    main()
  File "/home/bernd/MagnetiCalc/magneticalc/__main__.py", line 47, in main
    gui = GUI()
  File "/home/bernd/MagnetiCalc/magneticalc/GUI.py", line 109, in __init__
    self.reload()
  File "/home/bernd/MagnetiCalc/magneticalc/GUI.py", line 117, in reload
    self.sidebar_left.wire_widget.reload()
  File "/home/bernd/MagnetiCalc/magneticalc/Wire_Widget.py", line 299, in reload
    self.rotational_symmetry_count_spinbox.setValue(self.gui.project.get_float("rotational_symmetry_count"))
TypeError: setValue(self, int): argument 1 has unexpected type 'float'
GUI.cleanup()

Goodbye!

Bug: Crashes with open loops

Description: When calculating the field with loops where the end point is not the same as the start point, the program crashes just after the calculation finishes

WARNING: Traceback (most recent call last):
  File "<filter>/.local/lib/python3.7/site-packages/magneticalc/CalculationThread.py", line 180, in on_parameters_valid
    self.gui.model.on_parameters_valid()
  File "<filter>/.local/lib/python3.7/site-packages/magneticalc/Model.py", line 269, in on_parameters_valid
    self.gui.sidebar_right.parameters_widget.update_labels()
  File "<filter>/.local/lib/python3.7/site-packages/magneticalc/Parameters_Widget.py", line 154, in update_labels
    self.energy_units_label.setText(energy_value.split(" ")[1])
IndexError: list index out of range
Aborted (core dumped)

The problem is coming from update_labels in Parameters_Widget.py. Perhaps changing line 154 to self.energy_units_label.setText(energy_value.split(" ")[-1]) would fix it. Otherwise a try-catch might be required.

Platform:

Kernel: 5.4.0-91-generic x86_64
bits: 64
compiler: gcc v: 7.5.0
Desktop: Cinnamon 4.4.8
Distro: Linux Mint 19.3 Tricia base: Ubuntu 18.04 bionic
Python 3.7.4

Also tested (less thoroughly) with Windows 10 and Python 3.8. Both installed via pip.

Minimal example

[DEFAULT]
version = MagnetiCalc v1.9
backend = 0
auto_calculation = True
num_cores = 0
wire_points_base = -0.500000, +0.000000, +0.000000; +0.500000, +0.000000, +0.000000
wire_stretch = 0.1000, 1.0000, 1.0000
wire_slicer_limit = 0.0500
wire_dc = 1.0000
rotational_symmetry_count = 30
rotational_symmetry_radius = 1.0000
rotational_symmetry_axis = 2
rotational_symmetry_offset = 0
sampling_volume_padding = 1, 1, 1
sampling_volume_resolution_exponent = 3
sampling_volume_label_resolution_exponent = 0
field_type = 1
field_distance_limit = 0.0008
color_metric = Log Magnitude
alpha_metric = Magnitude
field_point_scale = 0.0000
field_arrow_head_scale = 0.7500
field_arrow_line_scale = 0.7500
field_boost = 0.0000
display_field_magnitude_labels = True
show_wire_segments = True
show_wire_points = True
show_colored_labels = True
show_coordinate_system = True
show_perspective_info = True
dark_background = True
azimuth = 135
elevation = 35.264389682754654
scale_factor = 3.0000
constraint_count = 0

[User]
auto_calculation = False
rotational_symmetry_count = 1
rotational_symmetry_radius = 0.0000
rotational_symmetry_axis = 2
rotational_symmetry_offset = 0.0000
wire_stretch = +1.000000, +1.000000, +1.000000

Feature Request: Manual override of sampling volume

It would be nice to allow the user to choose the bounds of the sampling volume rather than always creating a volume big enough to cover the coils.
This would be useful in the case of large coils where the user only needs to know the field close to the origin so that the number of points computed can be greatly reduced.

Pip version doesn't launch

When installed via pip the program doesn't launch on python -m magneticalc with error ModuleNotFoundError: No module named 'magneticalc.QtWidgets2'

I suspect the reason is that the directory is not specified in line 27 of setup.py: package_dir={"magneticalc": "magneticalc"}.
Since there are already __init__.py files in the main and sub directories it might be possible to change the file to

from setuptools import setup, find_packages

version = {}
with open("magneticalc/Version.py") as file:
    exec(file.read(), version)

setup(
    packages=find_packages()
    name="MagnetiCalc",
...

But I'm not sure because I don't have much experience making PyPI releases.

Feature request: loading and saving of data

I found the user interface very intuitive and the calculation seems efficient on my CPU (I don't have a GPU in my laptop).
To enhance usability, I would suggest two changes:

  1. Allow loading a wire by points defined in a text file.
  2. Allow saving the calculated field to a file (I recommend hdf5 for this use case, see below).

Both of these features would allow computation of complex current geometries. The first allowing one to use numpy (or whatever else) to define the coils numerically and then load in the points without having to fill the table by hand. The second would allow one to take the calculated fields of different sets of coils and combine them with the superposition principle and also calculate quantities such as curvature.

Why I think hdf5 is the most suitable file format:
First, the h5py library is excellent for reading and writing these file types.
The file is structured like a dictionary in Python.
Imagine that the evaluation volume is defined by X, Y, Z = numpy.meshgrid(x,y,z) and we have the calculated fields, A and B, which each have three components: A = (A_x, A_y, A_z), B = (B_x, B_y, B_z).
We construct a dictionary
fields = {'x': x, 'y': y, 'z': z, 'A_x': A_x, 'A_y': A_y, 'A_z': A_z, 'B_x': B_x, 'B_y': B_y, 'B_z': B_z}
We can also take the geometry of the wire from Points (here I write xp, yp, zp, I haven't checked the source code for the actual variable names). Let's assume these are the points after stretch and rotate
points = {'x': xp, 'y': yp, 'z': zp}
data = {'fields': fields, 'points': points, 'current': wirecurrent}
To write it in a .h5 file we do

import h5py

def Dict2Group(h5group,data):
    keys = data.keys()
    for key in keys:
        if (isinstance(data[key],dict)):
            group = h5group.create_group(key)
            Dict2Group(group,data[key])
        else:
            h5group[key] = data[key]
    return

f = h5py.File(filename,'w')
Dict2Group(f,data)
f.close()

Then, all of the information which the user could possibly want is saved in one single file for later processing.

AttributeError: 'CanvasBackend' object has no attribute 'setFocusPolicy' GUI.quit()

Hello,

I've installled it and want to start.

python3 -m pip install magneticalc --upgrade
python3 -m magneticalc

That's the Error log:

MagnetiCalc v1.8.6
Copyright © 2020, Paul Wilhelm, M. Sc. <mailto:[email protected]>
ISC License (see README.md)


main/GUI: Init
main/__init__/Config.set_filename: file:///home/kris/MagnetiCalc/MagnetiCalc.ini
main/__init__/Config.load()
main/__init__/Model: Init
main/__init__/__init__/__init__/Wire_Widget.reinitialize()
main/__init__/__init__/__init__/reinitialize/set_wire/ModelAccess.enter()
main/__init__/__init__/__init__/reinitialize/set_wire/Wire: Init
main/__init__/__init__/__init__/reinitialize/set_wire/__init__/Wire.stretch()
main/__init__/__init__/__init__/reinitialize/set_wire/__init__/Wire._set_rotational_symmetry()
main/__init__/__init__/__init__/reinitialize/set_wire/ModelAccess.exit()
main/__init__/__init__/__init__/SamplingVolume_Widget.reinitialize()
main/__init__/__init__/__init__/reinitialize/Constraint_Editor.reinitialize()
main/__init__/__init__/__init__/reinitialize/set_sampling_volume/ModelAccess.enter()
main/__init__/__init__/__init__/reinitialize/set_sampling_volume/SamplingVolume: Init
main/__init__/__init__/__init__/reinitialize/set_sampling_volume/SamplingVolume_Widget.readjust()
main/__init__/__init__/__init__/reinitialize/set_sampling_volume/ModelAccess.exit()
main/__init__/__init__/__init__/Field_Widget.reinitialize()
main/__init__/__init__/__init__/reinitialize/set_field/ModelAccess.enter()
main/__init__/__init__/__init__/reinitialize/set_field/Field: Init
main/__init__/__init__/__init__/reinitialize/set_field/ModelAccess.exit()
main/__init__/__init__/__init__/Metric_Widget.reinitialize()
main/__init__/__init__/__init__/reinitialize/set_metric/ModelAccess.enter()
main/__init__/__init__/__init__/reinitialize/set_metric/Metric: Init
main/__init__/__init__/__init__/reinitialize/set_metric/ModelAccess.exit()
main/__init__/__init__/__init__/Parameters: Init
main/__init__/__init__/__init__/Display_Widget.reinitialize()
main/__init__/__init__/__init__/reinitialize/Display_Widget.update_label_resolution_combobox()
WARNING: Although PyQt5 is already imported, the PyQt5 backend could not
be used ("cannot import name 'QtOpenGL' from 'PyQt5' (/usr/lib/python3/dist-packages/PyQt5/__init__.py)"). 
Note that running multiple GUI toolkits simultaneously can cause side effects.

(python3:52051): Gtk-WARNING **: 18:42:24.449: gtk_disable_setlocale() must be called before gtk_init()
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/kris/MagnetiCalc/magneticalc/__main__.py", line 49, in <module>
    main()
  File "/home/kris/MagnetiCalc/magneticalc/__main__.py", line 39, in main
    gui = GUI()
  File "/home/kris/MagnetiCalc/magneticalc/GUI.py", line 84, in __init__
    self.vispy_canvas.native.setFocusPolicy(Qt.NoFocus)  # Don't let VisPy gain control -- handle all events in GUI
AttributeError: 'CanvasBackend' object has no attribute 'setFocusPolicy'
GUI.quit()

Goodbye!

Any Ideas?

Replicating an air coil

Hello Sir,
Not an issue, but a question instead. Is there any way to copy the loops from the Magpy package to the GUI Magnetic Calc? I tried looking at the documentation for Magpy, but I cannot get every (X,Y,Z) coordinate every loop creates.
Below I attached a video of one loop I created (Magpy)- and in your GUI, I must specify every X,Y, and Z coordinates to form a loop like the one below, either manually or via a text file, and this becomes tedious for me since I am unable to get every coordinate to perfectly copy the loop from Magpy to MagnetiCalc.

loop.mp4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.