Skip to content

Commit

Permalink
performance test stiffness matrix: imprpved plot by including linear fit
Browse files Browse the repository at this point in the history
  • Loading branch information
leuraph committed Jan 23, 2024
1 parent e93a4d4 commit 3c5fc90
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Binary file modified figures/stiffness_matrix_assembly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion p1afempy/tests/manual/performance_test_stiffnes_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from p1afempy import solvers
from p1afempy import refinement
from pathlib import Path
from scipy.stats import linregress


class TestResult:
Expand Down Expand Up @@ -44,7 +45,7 @@ def main() -> None:
boundaries = [boundary_0, boundary_1]

# specifying statistics
n_refinements =11
n_refinements = 11
n_repetetitions_each = 20

test_results: list[TestResult] = []
Expand Down Expand Up @@ -74,6 +75,9 @@ def main() -> None:
means = np.array([np.mean(result.times) for result in test_results])
stdvs = np.array([np.std(result.times) for result in test_results])

# Fit a straight line (y = mx + q) using linregress
res = linregress(n_elements[-4:], means[-4:])

# read matlab results
path_to_matlab_means = Path(
'tests/data/matlab_performance/'
Expand All @@ -99,6 +103,10 @@ def main() -> None:
ax.errorbar(n_elements[cut_at:], means[cut_at:], stdvs[cut_at:],
fmt='x', label='Python', color='green',
capsize=2, capthick=1, elinewidth=1, markersize=4)
ax.loglog(n_elements[cut_at:],
res.slope * n_elements[cut_at:],
linestyle='--', color='black', linewidth=0.5,
label=r'$\propto M$')

# plot matlab results
ax.errorbar(matlab_n_elements[cut_at:],
Expand All @@ -113,6 +121,8 @@ def main() -> None:
ax.set_xscale('log')
ax.set_yscale('log')

ax.set_xlim(left=1e2)

ax.grid()
ax.legend(loc='best')
fig.savefig('stiffness_matrix_assembly.png')
Expand Down

0 comments on commit 3c5fc90

Please sign in to comment.