Skip to content

Commit

Permalink
content: after tech hour
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnivin committed Oct 23, 2024
1 parent 0009cc2 commit 8d907a2
Show file tree
Hide file tree
Showing 8 changed files with 842 additions and 182 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.png
*.png
*.jpg
*/__pycache__/*
.mypy_cache
__pycache__
__pycache__
*ipynb_*
295 changes: 295 additions & 0 deletions data/pisa_results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
{
"message": "Successfully retreived PISA calibration results from simple_without_damping simulation",
"results_along_the_pile": [
{
"z": 0,
"Mx": 0,
"Qx": 50000,
"ux": 1.0531,
"rotation": 0.0453225,
"LoadStep": 20
},
{
"z": 1,
"Mx": 47115,
"Qx": 48760,
"ux": 1.0028,
"rotation": 0.04526625,
"LoadStep": 20
},
{
"z": 2,
"Mx": 93395,
"Qx": 47480,
"ux": 0.9528,
"rotation": 0.045092499999999994,
"LoadStep": 20
},
{
"z": 3,
"Mx": 138150,
"Qx": 45890,
"ux": 0.90315,
"rotation": 0.0448075,
"LoadStep": 20
},
{
"z": 4,
"Mx": 181450,
"Qx": 44260,
"ux": 0.854,
"rotation": 0.044416250000000004,
"LoadStep": 20
},
{
"z": 5,
"Mx": 223200,
"Qx": 42670,
"ux": 0.80821,
"rotation": 0.04425,
"LoadStep": 20
},
{
"z": 6,
"Mx": 263050,
"Qx": 40920,
"ux": 0.76267,
"rotation": 0.04405,
"LoadStep": 20
},
{
"z": 7,
"Mx": 300800,
"Qx": 39050,
"ux": 0.7174,
"rotation": 0.043818750000000004,
"LoadStep": 20
},
{
"z": 8,
"Mx": 336500,
"Qx": 37100,
"ux": 0.67244,
"rotation": 0.04355875,
"LoadStep": 20
},
{
"z": 9,
"Mx": 370050,
"Qx": 35050,
"ux": 0.62783,
"rotation": 0.043268749999999995,
"LoadStep": 20
},
{
"z": 10,
"Mx": 394350,
"Qx": 32880,
"ux": 0.5836,
"rotation": 0.042952500000000005,
"LoadStep": 20
},
{
"z": 14.5,
"Mx": 459900,
"Qx": 18720,
"ux": 0.39088,
"rotation": 0.04137125,
"LoadStep": 20
},
{
"z": 19,
"Mx": 415350,
"Qx": -3937,
"ux": 0.20899,
"rotation": 0.0397475,
"LoadStep": 20
},
{
"z": 23.5,
"Mx": 255600,
"Qx": -29340,
"ux": 0.037577,
"rotation": 0.03851875,
"LoadStep": 20
},
{
"z": 28,
"Mx": 83780,
"Qx": -35550,
"ux": -0.12872,
"rotation": 0.03791375,
"LoadStep": 20
}
],
"results_at_seabead": [
{
"Hx": 0,
"LoadStep": 0,
"My": 0,
"ux": 0.0,
"rotation": 0.0,
"z": 0
},
{
"Hx": 2500,
"LoadStep": 1,
"My": 0,
"ux": 0.002364,
"rotation": -0.0001438,
"z": 0
},
{
"Hx": 5000,
"LoadStep": 2,
"My": 0,
"ux": 0.006516,
"rotation": -0.0003997,
"z": 0
},
{
"Hx": 7500,
"LoadStep": 3,
"My": 0,
"ux": 0.01229,
"rotation": -0.0007388,
"z": 0
},
{
"Hx": 10000,
"LoadStep": 4,
"My": 0,
"ux": 0.01963,
"rotation": -0.00115,
"z": 0
},
{
"Hx": 12500,
"LoadStep": 5,
"My": 0,
"ux": 0.02859,
"rotation": -0.001631,
"z": 0
},
{
"Hx": 15000,
"LoadStep": 6,
"My": 0,
"ux": 0.03928,
"rotation": -0.002184,
"z": 0
},
{
"Hx": 17500,
"LoadStep": 7,
"My": 0,
"ux": 0.05214,
"rotation": -0.002827,
"z": 0
},
{
"Hx": 20000,
"LoadStep": 8,
"My": 0,
"ux": 0.06792,
"rotation": -0.003592,
"z": 0
},
{
"Hx": 22500,
"LoadStep": 9,
"My": 0,
"ux": 0.08723,
"rotation": -0.004507,
"z": 0
},
{
"Hx": 25000,
"LoadStep": 10,
"My": 0,
"ux": 0.1115,
"rotation": -0.005632,
"z": 0
},
{
"Hx": 27500,
"LoadStep": 11,
"My": 0,
"ux": 0.1422,
"rotation": -0.007025,
"z": 0
},
{
"Hx": 30000,
"LoadStep": 12,
"My": 0,
"ux": 0.1802,
"rotation": -0.008723,
"z": 0
},
{
"Hx": 32500,
"LoadStep": 13,
"My": 0,
"ux": 0.2303,
"rotation": -0.01091,
"z": 0
},
{
"Hx": 35000,
"LoadStep": 14,
"My": 0,
"ux": 0.2866,
"rotation": -0.01335,
"z": 0
},
{
"Hx": 37500,
"LoadStep": 15,
"My": 0,
"ux": 0.3569,
"rotation": -0.01635,
"z": 0
},
{
"Hx": 40000,
"LoadStep": 16,
"My": 0,
"ux": 0.4467,
"rotation": -0.02013,
"z": 0
},
{
"Hx": 42500,
"LoadStep": 17,
"My": 0,
"ux": 0.5561,
"rotation": -0.02472,
"z": 0
},
{
"Hx": 45000,
"LoadStep": 18,
"My": 0,
"ux": 0.6903,
"rotation": -0.0303,
"z": 0
},
{
"Hx": 47500,
"LoadStep": 19,
"My": 0,
"ux": 0.8552,
"rotation": -0.03713,
"z": 0
},
{
"Hx": 50000,
"LoadStep": 20,
"My": 0,
"ux": 1.053,
"rotation": -0.04532,
"z": 0
}
]
}
28 changes: 14 additions & 14 deletions demo/damped_sine_optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
"source": [
"np.random.seed(2021) # Set random seed for reproducibility\n",
"\n",
"amp = 5.0\n",
"amplitude = 5.0\n",
"omega = 2.0\n",
"shift = -0.1\n",
"decay = 0.025\n",
"phi = -0.1\n",
"gamma = 0.025\n",
"\n",
"x = np.linspace(0, 15, 301)\n",
"data = amp * np.sin(omega * x + shift) * np.exp(-x * x * decay) + np.random.normal(\n",
"data = amplitude * np.sin(omega * x + phi) * np.exp(-x * x * gamma) + np.random.normal(\n",
" size=x.size, scale=0.2\n",
")\n",
"\n",
Expand Down Expand Up @@ -69,9 +69,9 @@
"source": [
"def residual(parameters, x, data):\n",
" model = (\n",
" parameters[\"amp\"]\n",
" * np.sin(x * parameters[\"omega\"] + parameters[\"shift\"])\n",
" * np.exp(-x * x * parameters[\"decay\"])\n",
" parameters[\"amplitude\"]\n",
" * np.sin(x * parameters[\"omega\"] + parameters[\"phi\"])\n",
" * np.exp(-x * x * parameters[\"gamma\"])\n",
" )\n",
" return model - data"
]
Expand All @@ -91,15 +91,15 @@
"outputs": [],
"source": [
"parameters_initial = create_params(\n",
" amp=dict(value=10, min=0),\n",
" decay=0.1,\n",
" amplitude=dict(value=10, min=0),\n",
" gamma=0.1,\n",
" omega=3.0,\n",
" shift=dict(value=0.2, min=-np.pi / 2.0, max=np.pi / 2),\n",
" phi=dict(value=0.2, min=-np.pi / 2.0, max=np.pi / 2),\n",
")\n",
"\n",
"initial_model = (\n",
" parameters_initial[\"amp\"].value\n",
" * np.sin(x * parameters_initial[\"omega\"].value + parameters_initial[\"shift\"].value)\n",
" parameters_initial[\"amplitude\"].value\n",
" * np.sin(x * parameters_initial[\"omega\"].value + parameters_initial[\"phi\"].value)\n",
" * np.exp(-x * x * parameters_initial[\"decay\"].value)\n",
")\n",
"\n",
Expand Down Expand Up @@ -164,7 +164,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "demo-BCeWmlrf-py3.12",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -181,5 +181,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
6 changes: 3 additions & 3 deletions demo/illustration_plots/damped_sine.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ def residual(parameters, x, data):
# Additional plot: true model
true_model = amp * np.sin(omega * x + shift) * np.exp(-x * x * decay)

# Plotting the data and the true model

plt.figure()
plt.scatter(x, data, label="Data", color="red", alpha=0.6)
plt.plot(x, true_model, "--", label="True", color="green", linewidth=2)
# plt.plot(x, true_model, "--", label="True", color="green", linewidth=2)

# Adding the true model expression as text
model_text = r"$y = %.f \sin(%.f x %.2f) \, e^{-x^2 \cdot %.3f}$" % (
Expand All @@ -70,7 +70,7 @@ def residual(parameters, x, data):
shift,
decay,
)
plt.text(0.5, 0.8, model_text, fontsize=12, transform=plt.gca().transAxes)
# plt.text(0.5, 0.8, model_text, fontsize=12, transform=plt.gca().transAxes)

plt.xlabel("x")
plt.ylabel("y")
Expand Down
Loading

0 comments on commit 8d907a2

Please sign in to comment.