From 10 finite-element runs to your first surrogate — a NumPy mini-lab #10
haoming-luo
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
What does it actually mean to turn simulations into training data?
I have published a small, runnable example using ten AgentFEM cantilever calculations. The geometry and loading stay fixed; Young modulus changes. The resulting CSV fits in a few lines, and the surrogate needs only NumPy. No GPU, MPI installation, or LLM account is needed to try the learning part.
Download the mini-lab: code + data + provenance
Open the interactive notebook in Colab — compare E and 1/E features, plot the results, and change the query stiffness. You can also download the notebook and run it in local Jupyter. Colab may request sign-in to start its runtime.
Download
fit_surrogate.pyandcantilever.csvinto the same directory first. The optional--plotflag uses Matplotlib.A useful experiment
The baseline uses a straight line in Young modulus E. For this fixed, linear-elastic problem, displacement actually scales with 1/E. Try changing the feature to 1/E and compare the held-out predictions. It is a small example of physical knowledge improving the model—not a competition to use the largest network.
The default eight-training/two-test split produced 1.412% relative L2 error in this run. That is one tiny teaching split, not a general accuracy guarantee. The observable is the global maximum absolute displacement degree of freedom, in mm. The data are synthetic FEM results, not material test measurements. AgentFEM 0.3.3 and DOLFINx 0.11.0 were used; source and data hashes are included.
Go further
Which next input would make this example useful to you: geometry, load direction, or material nonlinearity? A concrete engineering question is welcome.
中文
从十次有限元计算到第一个代理模型:这个小案例把数据、代码和来源一起公开。只用 NumPy 就能动手看懂“仿真如何变成预测”。还可以把 E 换成 1/E 作为特征,观察一个简单的力学关系如何改善预测。欢迎分享你更想研究的几何、载荷或材料问题。
— Haoming Luo, AgentFEM maintainer
All reactions