Skip to content

Commit

Permalink
Update the docs and make interpolation optional (#10)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes

- **New Features**
  - Added optional curve interpolation with configurable sample points.
  - Introduced a new data file for magnetic field strength measurements.
- Enhanced datasets with new entries and updated formatting for existing
data files.

- **Documentation**
- Updated README with detailed usage instructions for the Jiles-Atherton
system identification tool.
- Added clarifications on interpolation and parameter specifications,
including an output symbol legend.

- **Bug Fixes**
  - Improved handling of reference curve data with repeated values.

- **Chores**
- Updated GitHub Actions workflow timeout duration from 120 to 180
minutes.
  - Modified test configurations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
pavel-kirienko authored Jan 30, 2025
1 parent ce033a3 commit 8e868a8
Show file tree
Hide file tree
Showing 23 changed files with 796 additions and 219 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
nox:
timeout-minutes: 120
timeout-minutes: 180
runs-on: ubuntu-latest
if: >
github.event_name == 'pull_request' ||
Expand Down
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ so it may be a good idea to create a dedicated directory for this purpose.

```shell
# Fit the example curve from Altair Flux:
jafit model=venk ref="data/Altair_Flux_HystereticExample.csv"
jafit model=venk ref="data/B(H).Altair_Flux.Example.csv" interpolate=300

# Find coefficients for isotropic AlNiCo 5:
jafit model=venk ref="data/B(H).AlNiCo_5.tab"
jafit model=venk ref="data/B(H).Jesenik.AlNiCo.tab"
```

Output symbol legend per function evaluation:
💚 -- best match so far; ❌ -- no solution (convergence failure); 🔵 -- solution exists but is not the best.
Use `quiet=1` to reduce the verbosity.

The input reference curve file must contain two columns: H \[A/m\] and B \[T\], either tab- or comma-separated.
The first row may or may not be the header row.

Expand All @@ -59,10 +63,27 @@ e.g., only a part of the descending branch.
If a full loop is provided, then that loop doesn't need to be the major loop;
the tool will simply use the H amplitude seen in the reference loop for solving the JA equation.

Option `interpolate=N`, where N is a positive integer, can be used to interpolate the reference curve
with N equidistant sample points distributed along its length. Note that this is not the same as sampling the curve
on a regular H-axis grid; the difference is that the used method ensures consistent Euclidean distances between
the sample points. This is useful with irregularly sampled curves, but may cause adverse effects if the reference
curves contain large gaps, as the interpolation error within the gaps may be large.

If interpolation is not used (it is not by default), then the optimizer will naturally assign higher importance
to the regions of the curve with higher density of sample points. This may be leveraged to great advantage
if the reference curve is pre-processed to leave out the regions that are less important for the fitting.

If the reference curve is only a part of the hysteresis loop,
then the tool will use simple heuristics to guess the reasonable H amplitude for solving the JA equation,
assuming that the loop is the major loop (i.e., it reaches saturation).
In this case, it is recommended to specify `H_amp_min`/`H_amp_max` explicitly instead of relying on heuristics.
In this case, it is recommended to specify `H_amp_min` and/or `H_amp_max` explicitly instead of relying on heuristics.

`H_amp_min` specifies the minimum H magnitude that must be reached before switching the H sweep direction,
and `H_amp_max` is the maximum H magnitude that the solver is allowed to use; the solver will flip the H sweep
direction somewhere between these two values as soon as the material reaches saturation ($\chi^\prime$ becomes small).

If the loop is known to be the major loop, then it is occasionally useful to manually extend `H_amp_max` a little
to ensure that the material reaches deep saturation, so that the optimizer converges to a good $M_s$ value faster.

Optionally, you can provide the initial guess for (some of) the coefficients: `c_r`, `M_s`, `a`, `k_p`, `alpha`.

Expand Down Expand Up @@ -123,6 +144,14 @@ jafit model=venk H_amp_max=65e3 c_r=0.1 M_s=1.6e6 a=560 k_p=1200 alpha=0.0007

<img src="validation/jafit-comsol-default-material.png" alt="" height="200px"><img src="validation/hysteresis-comsol-default-material.png" alt="" height="200px">

#### Specimen B: LNGT72 approximation

```shell
jafit model=venk c_r=0.00000098783341818 M_s=0931849.980906066 a=025958.529588940 k_p=147381.227474120 alpha=0.17527880356890363 H_amp_min=1e6
```

<img src="validation/jafit hysteresis model=venk c_r=0.00000098783341818 M_s=0931849.980906066 a=025958.529588940 k_p=147381.227474120 alpha=0.17527880356890363.png" alt="" height="200px"><img src="validation/hysteresis model=venk c_r=0.00000098783341818 M_s=0931849.980906066 a=025958.529588940 k_p=147381.227474120 alpha=0.17527880356890363.png" alt="" height="200px">

### Against Altair Flux

The following invocation results in a curve matching the example material from Altair Flux.
Expand Down
40 changes: 0 additions & 40 deletions data/B(H).AlNiCo_5.tab

This file was deleted.

File renamed without changes.
17 changes: 17 additions & 0 deletions data/B(H).Ansys.AlNiCo_5-7.tab
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"H (A_per_meter)" "B (tesla)"
-59300 0
-58914 0.13
-58147 0.32400000000000001
-57258 0.52100000000000002
-56490 0.72099999999999997
-55237 0.92200000000000004
-53889 0.99099999999999999
-51934 1.0609999999999999
-49618 1.1200000000000001
-46577 1.167
-39653 1.2190000000000001
-31522 1.2490000000000001
-23392 1.272
-15503 1.3009999999999999
-7616 1.321
0 1.3320000000000001
File renamed without changes.
21 changes: 21 additions & 0 deletions data/B(H).Ansys.LNG52.tab
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"H (A_per_meter)" "B (tesla)"
-56000 0
-55874 0.10717400000000001
-55722.400000000001 0.21434800000000001
-55536.300000000003 0.321521
-55302.800000000003 0.42869499999999999
-55000.699999999997 0.53586900000000004
-54594.900000000001 0.64304300000000003
-54020.800000000003 0.75021599999999999
-53146.400000000001 0.85738999999999999
-51652.5 0.96456399999999998
-48519.300000000003 1.0717399999999999
-43128.300000000003 1.1457200000000001
-37737.300000000003 1.17906
-32346.200000000001 1.19834
-26955.200000000001 1.2152799999999999
-21564.200000000001 1.23221
-16173.1 1.24915
-10782.1 1.2660899999999999
-5391.04 1.28302
0 1.3
47 changes: 47 additions & 0 deletions data/B(H).Campbell.AlNiCo_5.tab
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
H B
172437.400000 1.547170
150113.800000 1.518142
124145.800000 1.494920
100227.800000 1.457184
76082.000000 1.416546
50113.800000 1.375908
25968.200000 1.335268
3872.400000 1.300436
0.000000 1.291728
-19817.800000 1.236574
-31890.600000 1.184326
-43052.400000 1.100146
-49886.200000 0.998548
-54669.800000 0.830188
-55808.600000 0.560232
-56036.400000 0.301886
-56492.000000 0.133526
-56719.800000 0.000000
-56947.600000 -0.136430
-66287.000000 -1.149492
-90660.600000 -1.341074
-151025.000000 -1.526850
-181549.000000 -1.576198
-151252.800000 -1.526850
-124829.200000 -1.492018
-100911.200000 -1.448476
-76082.000000 -1.407838
-50569.400000 -1.367198
-27107.000000 -1.320754
-3872.400000 -1.277214
455.600000 -1.259796
17539.800000 -1.216256
26195.800000 -1.181422
38268.800000 -1.111756
47836.000000 -1.004354
52619.600000 -0.870828
55808.600000 -0.502178
56492.000000 -0.287374
56719.800000 -0.075472
56720.000000 -0.002902
57175.400000 0.098694
60820.000000 0.981132
70615.000000 1.222060
99088.800000 1.390420
149886.200000 1.521044
172665.200000 1.547170
136 changes: 136 additions & 0 deletions data/B(H).Ibrayeva.LNGT40.tab
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
H B
400000.000000 1.641026
379906.000000 1.605770
358555.600000 1.576924
334066.000000 1.544872
316483.600000 1.506410
299529.200000 1.483974
279434.800000 1.458334
259340.800000 1.423076
239246.400000 1.403846
219780.400000 1.368590
203453.600000 1.336538
178336.000000 1.307692
149450.400000 1.253206
128728.400000 1.227564
111146.000000 1.185898
96075.200000 1.153846
81004.800000 1.131410
62166.400000 1.102564
47095.600000 1.060898
34536.800000 1.044872
25745.600000 1.016026
13186.800000 1.000000
6279.600000 0.974358
-3767.600000 0.948718
-10047.200000 0.926282
-20722.000000 0.903846
-30141.200000 0.868590
-37048.800000 0.849358
-47723.600000 0.820512
-58398.800000 0.778846
-67818.000000 0.743590
-74097.200000 0.708334
-81632.800000 0.685898
-87912.000000 0.650642
-94191.600000 0.615384
-100470.800000 0.576924
-106122.400000 0.538462
-111774.000000 0.490384
-114285.600000 0.432692
-120565.200000 0.403846
-120965.200000 0.355770
-124332.800000 0.304488
-126216.800000 0.269230
-127472.400000 0.214744
-129984.400000 0.157052
-130612.400000 0.121794
-131240.000000 0.086538
-132496.000000 0.048076
-132500.000000 0.012820
-133752.000000 -0.019230
-133756.000000 -0.067308
-133760.000000 -0.269230
-133760.400000 -0.429488
-134380.000000 -0.586538
-137519.600000 -0.743590
-142543.200000 -0.887820
-150706.400000 -1.012820
-167032.800000 -1.125000
-195918.400000 -1.256410
-243642.000000 -1.368590
-311460.000000 -1.493590
-367346.800000 -1.580128
-400628.000000 -1.625000
-391208.800000 -1.612180
-381161.600000 -1.599358
-370486.800000 -1.586538
-359811.600000 -1.570512
-352276.400000 -1.557692
-344113.200000 -1.551282
-335322.000000 -1.535256
-327158.400000 -1.516026
-317111.600000 -1.500000
-306436.400000 -1.483974
-292621.600000 -1.480770
-286970.000000 -1.461538
-275667.200000 -1.461538
-267504.000000 -1.435898
-256828.800000 -1.423076
-248665.600000 -1.403846
-237362.800000 -1.391026
-225431.600000 -1.375000
-214128.800000 -1.349358
-203453.600000 -1.333334
-194034.400000 -1.326924
-174568.400000 -1.278846
-162637.200000 -1.278846
-149450.400000 -1.259616
-138147.600000 -1.233974
-128100.400000 -1.211538
-116797.600000 -1.192308
-104866.400000 -1.166666
-95447.600000 -1.157052
-86656.400000 -1.137820
-77237.200000 -1.115384
-66562.000000 -1.086538
-55259.200000 -1.064102
-45212.000000 -1.048076
-36420.800000 -1.028846
-24489.600000 -1.006410
-12558.800000 -0.983974
-3767.600000 -0.958334
5023.600000 -0.935898
15070.800000 -0.907052
28885.600000 -0.871794
38932.400000 -0.833334
48351.600000 -0.801282
58398.800000 -0.766026
67818.000000 -0.733974
76609.200000 -0.701924
83516.400000 -0.663462
89168.000000 -0.618590
96703.200000 -0.583334
104238.800000 -0.541666
109262.000000 -0.490384
114913.600000 -0.435898
119309.200000 -0.384616
124332.800000 -0.330128
125588.800000 -0.288462
129356.400000 -0.221154
129984.400000 -0.169872
131868.000000 -0.131410
133752.000000 -0.067308
134380.000000 -0.003206
135008.000000 0.054488
135635.600000 0.102564
136263.600000 0.358974
136891.600000 0.586538
139403.600000 0.750000
146310.800000 0.916666
157614.000000 1.038462
173312.400000 1.157052
201570.000000 1.272436
235478.800000 1.352564
288226.000000 1.461538
400000.000000 1.644230
Loading

0 comments on commit 8e868a8

Please sign in to comment.