Skip to content

Demo Notebooks

Sunil Anandatheertha edited this page Oct 6, 2026 · 13 revisions

Demo Notebooks Index

Demo notebooks are maintained in a separate repository, UPXO-demos (MIT license). They are not shipped inside the pip install upxo wheel. Folder names below (gsgen/, confMesh/) are folders of UPXO-demos. Notebooks are added to UPXO-demos as they are curated; this page lists the published ones.

pip install upxo
git clone https://github.com/Design-By-Fundamentals-UKAEA/UPXO-demos.git
cd UPXO-demos
jupyter lab

Concepts: Key Concepts. Problems: FAQ.


Grain structure generation

Notebook What you learn
gsgen/monte_carlo_2d_01.ipynb 2D Monte Carlo grain growth: instantiate mcgs, simulate temporal slices, detect grains, select a slice, characterise its morphology, explore the data structure and plot the state array

See 2D Grain Structure Generation.


2D conformal meshing

The 2D path is confMesh2dGMSH / gsmesh2d.mesh_gs (raw Gmsh). Requires gmsh (pip install upxo[mesh]).

Notebook What you learn
confMesh2d_gmsh.ipynb Canonical demo: mesh grain polygons, grain-coloured plot, ELSETs/NSETs, Abaqus .inp, from_geometric_pxtal
confMesh2d_export.ipynb Visualisation + Abaqus export (CPS3/CPE3, grain ELSETs, face NSETs)
confMesh2d_mcgs.ipynb Teaching path: MCGS → polygonise → smooth → confMesh2dGMSH → plot/export
confMesh2d_geometrify.ipynb Geometrification (polygonise + GB smooth) then handoff to mesh_gs
confMesh2d_technique_b.ipynb Technique B (GrainManifold2D Voronoi-from-LFI) then mesh_gs + plot/export
confMesh2d_compare_techniques.ipynb Technique A vs Technique B on the same label image: geometry, mesh quality, timing

Capability notebooks (each plots the mesh and writes an Abaqus .inp):

Notebook What you learn
confMesh2d_tri_vs_quad.ipynb Same polygons: linear triangles vs recombined quads; CPS3 vs CPS4
confMesh2d_islands_voids.ipynb Island grain (inclusion ELSET) vs interior void (hole, no ELSET)
confMesh2d_voronoi.ipynb vtpolyxtal2d seeds → from_geometric_pxtal → mesh (not Technique B)
confMesh2d_size_field.ipynb GB vs bulk Threshold field (mesh_size_gb / mesh_size_bulk)
confMesh2d_quadratic.ipynb mesh_order=2 (6-node tris); native .msh/.vtk; INP still linear corners
confMesh2d_quality.ipynb validation_report (counts, missing grains, degenerate, clockwise)
confMesh2d_nsets.ipynb Face, GB, and per-grain NSETs; INP writes NS_LEFT…NS_GB

All in confMesh/. Start at confMesh2d_gmsh.ipynb (MCGS teaching path: confMesh2d_mcgs.ipynb). See Meshing and 2D Grain Structure Geometrification.


3D conformal tet meshing

Notebook What you learn
confMesh/tet_mesh_v2p1_A.ipynb Voxel label array → cleaned labels → smoothed grain-boundary surfaces → closed, validated surface complex → one tet mesh per grain → quality improvement → Abaqus export, with element quality histograms and a clipped tet view. Uses the d3v2p1 stages. Bundled input: confMesh/tetmesh3d_data/25x25x25/voronoi_50grains.npy; set SAMPLE and RUN_DIR in the first code cell.

See GB-conformant 3D.


Tips

  1. Install UPXO into the same kernel as the notebook (pip install upxo, or pip install -e . from a clone of UPXO).
  2. Use Python ≥ 3.13.
  3. Start each notebook in a fresh kernel and run the cells in order.

Clone this wiki locally