/ challenges-old / string-solutions
Sign in
challenges-old / string-solutions
Regenerate for the equilibrium pluck initial condition (finger load of half-width 6 mm, scale 2.4 m/s)
Jeremy Magland <jmagland@flatironinstitute.org> committed commit 0e420221575a parent 8f29519 Browse files
18 changed files+30−20
solutions/string-pluck-v1/fd-second-order.jsonmodified+5−5View file
@@ -22,7 +22,7 @@
2222 "dt_s": 2.0833333333333333e-05,
2323 "courant": 0.898333
2424 },
25- "timing_seconds": 2.968,
25+ "timing_seconds": 2.012,
2626 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
2727 "more_accurate_than": []
2828 },
@@ -37,7 +37,7 @@
3737 "dt_s": 1.0416666666666666e-05,
3838 "courant": 0.898333
3939 },
40- "timing_seconds": 5.195,
40+ "timing_seconds": 4.455,
4141 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
4242 "more_accurate_than": [
4343 "fd-m1"
@@ -54,7 +54,7 @@
5454 "dt_s": 5.208333333333333e-06,
5555 "courant": 0.899479
5656 },
57- "timing_seconds": 12.217,
57+ "timing_seconds": 11.354,
5858 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
5959 "more_accurate_than": [
6060 "fd-m2"
@@ -71,7 +71,7 @@
7171 "dt_s": 2.6041666666666666e-06,
7272 "courant": 0.899479
7373 },
74- "timing_seconds": 32.797,
74+ "timing_seconds": 33.202,
7575 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
7676 "more_accurate_than": [
7777 "fd-m4"
@@ -88,7 +88,7 @@
8888 "dt_s": 1.3020833333333333e-06,
8989 "courant": 0.899766
9090 },
91- "timing_seconds": 117.533,
91+ "timing_seconds": 111.127,
9292 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
9393 "fields": {
9494 "path": "fd-second-order/fd-m16.h5",
solutions/string-pluck-v1/fd-second-order/fd-m1.wavmodified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/fd-second-order/fd-m16.h5modified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/fd-second-order/fd-m16.wavmodified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/fd-second-order/fd-m2.wavmodified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/fd-second-order/fd-m4.wavmodified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/fd-second-order/fd-m8.wavmodified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/modal-series.jsonmodified+7−7View file
@@ -18,7 +18,7 @@
1818 "parameters": {
1919 "n_modes": 4
2020 },
21- "timing_seconds": 0.0092,
21+ "timing_seconds": 0.0079,
2222 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
2323 "more_accurate_than": []
2424 },
@@ -29,7 +29,7 @@
2929 "parameters": {
3030 "n_modes": 8
3131 },
32- "timing_seconds": 0.0214,
32+ "timing_seconds": 0.0192,
3333 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
3434 "more_accurate_than": [
3535 "modal-n4"
@@ -42,7 +42,7 @@
4242 "parameters": {
4343 "n_modes": 16
4444 },
45- "timing_seconds": 0.0464,
45+ "timing_seconds": 0.0384,
4646 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
4747 "more_accurate_than": [
4848 "modal-n8"
@@ -55,7 +55,7 @@
5555 "parameters": {
5656 "n_modes": 32
5757 },
58- "timing_seconds": 0.091,
58+ "timing_seconds": 0.0714,
5959 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
6060 "more_accurate_than": [
6161 "modal-n16"
@@ -68,7 +68,7 @@
6868 "parameters": {
6969 "n_modes": 64
7070 },
71- "timing_seconds": 0.1391,
71+ "timing_seconds": 0.1264,
7272 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
7373 "more_accurate_than": [
7474 "modal-n32"
@@ -81,7 +81,7 @@
8181 "parameters": {
8282 "n_modes": 256
8383 },
84- "timing_seconds": 0.636,
84+ "timing_seconds": 0.5771,
8585 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
8686 "more_accurate_than": [
8787 "modal-n64"
@@ -94,7 +94,7 @@
9494 "parameters": {
9595 "n_modes": 1024
9696 },
97- "timing_seconds": 2.8862,
97+ "timing_seconds": 2.3304,
9898 "hardware": "13th Gen Intel(R) Core(TM) i7-1355U, single thread, Python 3.13.5 + numpy 2.4.4",
9999 "fields": {
100100 "path": "modal-series/modal-n1024.h5",
solutions/string-pluck-v1/modal-series/modal-n1024.h5modified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/modal-series/modal-n1024.wavmodified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/modal-series/modal-n16.wavmodified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/modal-series/modal-n256.wavmodified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/modal-series/modal-n32.wavmodified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/modal-series/modal-n4.wavmodified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/modal-series/modal-n64.wavmodified+0−0View file
Binary file not shown.
solutions/string-pluck-v1/modal-series/modal-n8.wavmodified+0−0View file
Binary file not shown.
solvers/common.pymodified+15−6View file
@@ -35,10 +35,19 @@ def hardware_string() -> str:
3535 return f"{cpu}, single thread, Python {platform.python_version()} + numpy {np.__version__}"
3636
3737
38+def pluck_load_q(p: dict) -> float:
39+ """Total load Q (a slope, force over tension) giving pluck height h at x_p."""
40+ return p["h"] / (p["x_p"] * (p["L"] - p["x_p"]) / p["L"] - p["w"] * (0.25 - 1.0 / np.pi**2))
41+
42+
3843 def initial_shape(x: np.ndarray, p: dict) -> np.ndarray:
39- """Raised-cosine pluck u_0(x) from the challenge spec."""
40- d = x - p["x_p"]
41- u = np.zeros_like(x)
42- m = np.abs(d) <= p["w"]
43- u[m] = 0.5 * p["h"] * (1.0 + np.cos(np.pi * d[m] / p["w"]))
44- return u
44+ """u_0(x): static equilibrium under the raised-cosine finger load, from the challenge spec."""
45+ L, xp, w = p["L"], p["x_p"], p["w"]
46+ Q = pluck_load_q(p)
47+ tri = np.where(x <= xp, x * (L - xp) / L, xp * (L - x) / L)
48+ y = x - xp
49+ cap = np.zeros_like(x)
50+ m = np.abs(y) <= w
51+ ym = y[m]
52+ cap[m] = ym * (ym > 0) - (1.0 / (2.0 * w)) * ((ym + w) ** 2 / 2.0 - (w**2 / np.pi**2) * (1.0 + np.cos(np.pi * ym / w)))
53+ return Q * (tri + cap)
solvers/modal/modal_string.pymodified+3−2View file
@@ -15,7 +15,7 @@ from pathlib import Path
1515 import numpy as np
1616
1717 sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
18-from common import hardware_string, load_challenge, write_wav # noqa: E402
18+from common import hardware_string, load_challenge, pluck_load_q, write_wav # noqa: E402
1919 from fields import field_grid, write_fields # noqa: E402
2020
2121
@@ -23,7 +23,8 @@ def modal_coefficients(p: dict, n_modes: int):
2323 n = np.arange(1, n_modes + 1)
2424 k = n * np.pi / p["L"]
2525 q = np.pi / p["w"]
26- A = (2.0 * p["h"] / p["L"]) * np.sin(k * p["x_p"]) * np.sin(k * p["w"]) * q**2 / (k * (q**2 - k**2))
26+ Q = pluck_load_q(p)
27+ A = (2.0 * Q / (p["L"] * p["w"] * k**3)) * np.sin(k * p["x_p"]) * np.sin(k * p["w"]) * q**2 / (q**2 - k**2)
2728 alpha = p["sigma0"] + 0.5 * p["kappa"] * k**2
2829 omega2 = (p["c"] * k) ** 2 - alpha**2
2930 if np.any(omega2 <= 0):
↑↓ move↵openescclose