replace analytical integration with numerical - #110
Conversation
|
@mamattern, could you please check this branch, if it still works without analytical integration? |
|
Here are some comparisons for different types of temperature dependence of the heat capacity using |
|
Following this thread Using In general the interpolation of experimental data should be avoided and a fit function should be used instead. |
|
instead of using def my_heat_capacity(T):
T = np.array(T)
res = np.ones_like(T, dtype=float)
select = T>=634
res[select] = -0.775/0.0718*np.abs((T[select]-634)/634)**0.0718 + 13.5+3.03*(T[select]-634)/634
select = T<634
res[select] =-2.46/0.0718*np.abs((T[select]-634)/634)**0.0718+37+3.03*(T[select]-634)/634
return res |
|
Using the numerical integration branch and the above defined heat capacity by: does not work and produces the following error: |
|
the problem is raised by |
|
removing the vectorization of the def my_heat_capacity(t):
if t >= 634:
return -0.775/0.0718*np.abs((t-634)/634)**0.0718 + 13.5+3.03*(t-634)/634
else:
return -2.46/0.0718*np.abs((t-634)/634)**0.0718+37+3.03*(t-634)/634 |
|
another option with vectorization would be using Ni_layer.heat_capacity = '(0.5*erf(634-T)+1)*(-2.46/0.0718*abs((T-634)/634)**0.0718+37+3.03*(T-634)/634) + (0.5*erf(T-634)+1)*(-0.775/0.0718*abs((T-634)/634)**0.0718 + 13.5+3.03*(T-634)/634)'this again works with the |
|
This does not work for me. I import If I use the private setting: |
|
I just fixed the errors from the Would be very interesting for the |
|
Now it works for me. I tested for numeric integration both possibilities: and the difference in the results is of the order e-10 and the calculation of the temperature after delta excitation took 7.4/7.2s, the calculation of the heat diffusion took 189/179s and the calculation of the strain map took 3.0/2.9s. As a comparison I also tested the analytic integration possibility by giving the heat capacity and linear thermal expansion coefficient and their integrals by |
|
okay, so without referring to the large difference in the To that I end, I would stick to the analytical integration of the |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #110 +/- ##
===========================================
- Coverage 86.13% 86.02% -0.11%
===========================================
Files 10 10
Lines 3216 3170 -46
===========================================
- Hits 2770 2727 -43
+ Misses 446 443 -3
🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 84.38%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | test_calc_energy_map |
95.6 ms | 612.1 ms | -84.38% |
| 🆕 | test_calc_sticks_from_temp_map |
N/A | 5 s | N/A |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing quadintegration (28cc962) with develop (e54254b)
Footnotes
-
6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
I did some performance testing using numerical vs analytical integration for the
So for 1. it actually does not matter much, at least for constant heat capacities. So in my view there are two option: A. just keep it as it is and integrate functions by hand if necessary |










following #109 the analytical integration can be replaced by numerical integration using
scipy.integrate.quad.This avoids doing the symbolig integration of the heat capacities and lin_therm_exp coefficients