Skip to content

Release version 0.4.0#8

Merged
peterhys merged 57 commits intomainfrom
release/v0.4.0
Oct 31, 2025
Merged

Release version 0.4.0#8
peterhys merged 57 commits intomainfrom
release/v0.4.0

Conversation

@peterhys
Copy link
Contributor

Version 0.4.0

Type of Pull Request

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test coverage improvement
  • Other (please describe):

Changes Made

Added Cylinder Magnet and minor fixes to docstrings and documentation.

Testing Performed

  • All existing tests pass (tox or pytest)
  • Added new tests for new functionality
  • Manual testing performed (describe below)

Documentation

  • Updated docstrings for new/modified functions and classes
  • Updated relevant documentation files (if applicable)
  • Added usage examples (if applicable)
  • Documentation builds without errors (cd docs && make html)

Checklist

  • Code follows PEP 8 style guidelines (use Black formatter's default settings)
  • Used meaningful variable and function names
  • Code is modular and readable
  • Commented code, particularly in hard-to-understand areas
  • Changes generate no new warnings or errors
  • PR focuses on a single feature or bug fix

SKeeTElor and others added 30 commits April 7, 2025 13:33
…ally, then convert to numpy function for vectorized calculation.
…t from the paper, the sqrt(1-k^2) is actually 1-k^2. Now fix it
2. add english comments to the code
3. fix the singularity problem when x^2+y^2=0 for Bzxx
4. use sympy. to replace sp.

To do: There might be another way to convert the sympy expression to a function: autowarp, need to try out.
…o I have sloved a bug in the magnet_cylinder.py.

-Now I am currently using 11 cuboids to approximate a cylinder. When viewed from the vertical direction, 11 rectangles are arranged side by side to simulate a circular shape. After testing, the relative error in regions with strong signals is less than 1%, and the runtime has been reduced by nearly 100 times. I have also written the corresponding test files.

-I discovered a bug in the old CylinderMagnet class: I had forgotten to account for the offset of the z-coordinate relative to the origin. This issue has now been fixed.
In the polarization function, the prolarization when x=0(relative to the center of the cylinder) is not nan due to we are calcutating 0/0. We used to think there gonna be all nan, however, it turns out to be incorrecte. So now the function will find the yz slice that has nan and replace it with the average of  2 slices new to it.

I also added a test for the polarization function.

There is another way to fix it, I calcuate the limit of the polarization function when x->0, but that need Bzxx, maybe I can write a new version in the future.
… returns NaN. Initially, I thought this was due to a 0/0 division in the middle of the x-axis. However, this issue can occur anywhere when the tip-sample separation is too small.

Now, in this function, it scans over the x-axis, identifies all NaN values, and replaces them with the average of their neighboring values.
CylinderMagnet.py use analytical solution to calculate the magnetic field, which is too long to calculate, so we decide to just use the approximate method.
The old test rely on CylinderMagnet, which is deleted now
These 2 files are no longger useful
@peterhys peterhys merged commit a91da07 into main Oct 31, 2025
7 checks passed
peterhys added a commit that referenced this pull request Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants