Revise spec to reserved-region FEM and add Phase 2 NX sandbox scripts

This commit is contained in:
2026-02-16 02:04:19 +00:00
parent 7086f9fbdf
commit 85d40898f0
6 changed files with 888 additions and 385 deletions

View File

@@ -21,11 +21,11 @@ After extensive brainstorming, the following decisions are locked:
| Decision | Choice | Rationale |
|---|---|---|
| Geometry generation | External Python (Constrained Delaunay) | Full access to scipy/triangle/gmsh, debuggable, fast |
| FEA strategy | Assembly FEM with superposed models | Decouples fixed interfaces (loads/BCs) from variable rib pattern |
| FEA strategy | Reserved-region monolithic remesh | Keep load/BC topology stable while allowing local rib updates |
| FEA solver | NX Simcenter + Nastran (2D shell) | Existing expertise, handles complex BCs, extensible to modal/buckling |
| NX role | Remesh plate model + merge nodes + solve | Geometry is agnostic to rib pattern; loads/BCs never re-associated |
| NX role | Extract sandbox faces, reimport profile, remesh + solve | Reserved regions preserve associations; no assembly merge pipeline needed |
| Optimization | Atomizer (Optuna TPE), pure parametric v1 | One FEA per trial, ~2 min/iteration, stress feedback deferred to v2 |
| Manufacturing | Through-cuts only (waterjet + CNC finish) | Simplifies geometry to 2D profile problem |
| Geometry transfer | JSON-only round trip | Deterministic, scriptable, no DXF/STEP conversion drift |
| Plate type | Flat, 200600 mm scale, 615 mm thick, 1630 holes | Shell elements appropriate, fast solves |
### System Diagram
@@ -34,27 +34,11 @@ After extensive brainstorming, the following decisions are locked:
ONE-TIME SETUP
══════════════
User in NX:
├── Select plate face → tool extracts boundary + holes → geometry.json
├── Partition plate mid-surface into regions:
│ ├── sandbox face(s): ISOGRID_SANDBOX = sandbox_1, sandbox_2, ...
│ └── reserved regions: edges/functional zones to stay untouched
├── Assign hole weights (interactive UI or table)
├── Build Assembly FEM:
│ ├── Model A — "Interface Model" (PERMANENT, never changes)
│ │ ├── Spider elements (RBE2/RBE3) at each hole center → circumference
│ │ ├── All loads applied to spider center nodes
│ │ ├── All BCs applied to spider center nodes or edge nodes
│ │ └── Edge BC nodes along plate boundary
│ │
│ ├── Model B — "Plate Model" (VARIABLE, rebuilt each iteration)
│ │ ├── 2D shell mesh of the ribbed plate profile
│ │ ├── Mesh seeds at hole circumference nodes (match Model A spiders)
│ │ └── Mesh seeds at edge BC nodes (match Model A edge nodes)
│ │
│ └── Assembly FEM
│ ├── Superpose Model A + Model B
│ ├── Merge nodes at hole circumferences + edges
│ └── Solver settings (SOL 101, SOL 103, etc.)
└── Verify: solve dummy Model B (solid plate), confirm results
└── Verify baseline solve and saved solution setup
OPTIMIZATION LOOP (~2 min/iteration)
════════════════════════════════════
@@ -64,58 +48,49 @@ Atomizer (Optuna TPE)
│ (η₀, α, β, p, R₀, κ, s_min, s_max, t_min, t₀, γ, w_frame, r_f, ...)
NXOpen Extractor (~seconds)
├── Find all sandbox faces by attribute
├── Extract each sandbox loop set to local 2D
└── Write geometry_sandbox_n.json
External Python — "The Brain" (~1-3 sec)
├── Load plate geometry + hole table (fixed)
├── Load geometry_sandbox_n.json
├── Compute density field η(x)
├── Generate constrained Delaunay triangulation
├── Compute rib thicknesses from density
├── Apply manufacturing constraints
── Validate geometry (min web, min pocket, no degenerates)
├── Output: rib_profile.json (curve coordinates)
└── Output: validity_flag + mass_estimate
── Write rib_profile_sandbox_n.json
NXOpen Journal — "The Hands" (~60-90 sec)
├── Delete old Model B geometry + mesh
├── Import new 2D ribbed profile (from rib_profile.json)
├── Create sheet body from profile curves
├── Mesh Model B with seeds at fixed interface nodes
├── Merge nodes in Assembly FEM (holes + edges)
NXOpen Import + Solve (~60-90 sec)
├── Replace sandbox geometry only
├── Keep reserved regions unchanged (loads/BCs persist)
├── Remesh full plate as monolithic model
├── Solve (Nastran)
└── Extract results (stress, displacement, strain, mass)
Result Extraction (~5-10 sec)
├── Von Mises stress field (nodal)
├── Displacement magnitude field (nodal)
├── Strain field (elemental)
├── Total mass
├── (Future: modal frequencies, buckling load factors)
└── Report metrics to Atomizer
└── Extract results.json (stress/disp/strain/mass)
Atomizer updates surrogate, samples next trial
Repeat until convergence (~500-2000 trials)
```
### Key Architectural Insight: Why Assembly FEM
### Key Architectural Insight: Why Reserved Regions
The plate lightweighting problem has a natural separation:
**What doesn't change:** Hole positions, hole diameters, plate boundary, loads, boundary conditions. These are the structural interfaces — where forces enter and leave the plate.
**What should stay fixed:** load/BC attachment topology around edges, holes, and functional interfaces.
**What changes every iteration:** The rib pattern between holes. This is purely the internal load-path topology.
**What should evolve:** the rib network inside the designable interior.
The Assembly FEM with superposed models exploits this separation directly. Model A captures everything fixed (interfaces, loads, BCs) using spider elements at holes and edge nodes at boundaries. Model B captures everything variable (the ribbed plate mesh). They connect through node merging at the fixed interface locations (hole circumferences and plate edges).
The reserved-region workflow maps directly to this separation. By only replacing
sandbox faces, all references in reserved zones remain valid while the interior
rib topology changes every iteration.
This means:
- Loads and BCs **never need re-association** — they live permanently on Model A
- Only Model B's mesh is rebuilt each iteration
- Node merging at fixed geometric locations is a reliable, automated operation in NX
- The solver sees one connected model with proper load paths through the spiders into the ribs
Atomizer updates surrogate, samples next trial
Repeat until convergence (~500-2000 trials)
```
- Loads and BCs persist naturally because reserved geometry is untouched
- No multi-model coupling layer or interface node reconciliation workflow
- Full-plate remesh remains straightforward and robust
- Geometry extraction runs each iteration, enabling hole-position optimization
---
@@ -577,341 +552,100 @@ These constraints are enforced during geometry generation, not as FEA post-check
---
## 4. The NX Hands: Assembly FEM Architecture
## 4. The NX Hands: Reserved-Region FEM Architecture
### 4.1 The Two-Model Structure
### 4.1 Core Concept: Sandbox + Reserved Regions
The FEA uses an Assembly FEM (AFEM) with two superposed finite element models. This is the standard aerospace approach for decoupling load introduction from structural detail, and it perfectly fits our problem where interfaces are fixed but internal topology varies.
The FEA workflow uses direct reserved-region remeshing rather than interface-coupling constructs.
**Model A — Interface Model (built once, never modified):**
Instead, each plate mid-surface is explicitly partitioned in NX into:
Model A contains only the structural interface elements. It has no plate geometry — just the load introduction and boundary condition hardware.
- **Sandbox region(s)** — where the adaptive isogrid is allowed to change each iteration
- **Reserved regions** — geometry that must remain untouched (edges, functional features, local areas around critical holes/BC interfaces)
For each hole:
- One node at the hole center (the "master" node)
- N nodes equally spaced on the hole circumference (N = 1224 depending on hole diameter, typically 1 node per ~2 mm of circumference)
- RBE2 or RBE3 spider element connecting center node to circumference nodes
- RBE2 (rigid): for bolted/pinned connections where the hole is rigidly constrained
- RBE3 (distributing): for bearing loads or distributed force introduction
Each sandbox face is tagged with an NX user attribute:
For plate boundary (edge BCs):
- Nodes distributed along the plate outer boundary at regular spacing (~25 mm)
- These serve as merge targets for Model B's edge mesh nodes
- **Title:** `ISOGRID_SANDBOX`
- **Value:** `sandbox_1`, `sandbox_2`, ...
All loads and boundary conditions are applied to Model A's nodes:
- Bolt forces → hole center nodes
- Fixed constraints → hole center nodes or edge nodes
- Bearing loads → hole center nodes (via RBE3)
- Enforced displacements → relevant center/edge nodes
- Pressures → applied directly to Model B elements (only exception)
Multiple sandbox faces are supported on the same plate.
**Model B — Plate Model (rebuilt each iteration):**
### 4.2 Iterative Geometry Round-Trip (JSON-only)
Model B is the 2D shell mesh of the current ribbed plate profile. It is the only model that changes during optimization. Key requirements:
Per optimization iteration, NXOpen performs a full geometry round-trip for each sandbox:
- Shell elements (CQUAD4/CTRIA3) with PSHELL property at plate thickness
- Mesh must have nodes at exact locations matching Model A's spider circumference nodes and edge BC nodes
- These "interface nodes" are enforced via mesh seed points (hard nodes) in NX's mesher
- The rest of the mesh fills in freely, adapting to the rib pattern geometry
1. **Extract current sandbox geometry** from NX into `geometry_sandbox_n.json`
- outer loop boundary
- inner loops (holes/cutouts)
- local 2D transform (face-local XY frame)
2. **Python Brain generates isogrid profile** inside sandbox boundary
- outputs `rib_profile_sandbox_n.json`
3. **NXOpen imports profile** and replaces only sandbox geometry
- reserved faces remain unchanged
4. **Full plate remesh** (single monolithic mesh)
5. **Solve existing Simcenter solution setup**
6. **Extract field + scalar results** to `results.json`
**Assembly FEM:**
- Superimposes Model A and Model B
- Merges coincident nodes at hole circumferences and plate edges (tolerance ~0.01 mm)
- After merge, loads flow from Model A's spiders through the merged nodes into Model B's shell mesh
- Solver settings, solution sequences, and output requests live at the assembly level
This JSON-only flow replaces DXF/STEP transfer for v1 and keeps CAD/CAE handoff deterministic.
### 4.2 One-Time Setup Procedure
### 4.3 Why Reserved-Region Is Robust
This is done once per plate project, before any optimization runs.
This architecture addresses the load/BC persistence problem by preserving topology where constraints live:
**Step 1 — Extract geometry and build Model A:**
- Loads and boundary conditions are assigned to entities in reserved regions that do not change between iterations
- Only sandbox geometry is replaced, so reserved-region references remain valid
- The solver always runs on one connected, remeshed plate model (no multi-model merge operations)
- Hole positions can be optimized because geometry extraction happens **every iteration** from the latest NX model state
```python
# NXOpen setup script — build the interface model
import NXOpen
import json
import math
### 4.4 NXOpen Phase-2 Script Responsibilities
def build_interface_model(geometry_json_path, fem_part):
"""
Build Model A: spider elements at each hole + edge BC nodes.
"""
with open(geometry_json_path) as f:
geometry = json.load(f)
#### A) `extract_sandbox.py`
interface_nodes = {
'hole_centers': [], # (hole_idx, node_id, x, y)
'hole_circumferences': [], # (hole_idx, node_id, x, y)
'edge_nodes': [] # (node_id, x, y)
}
- Discover all faces with `ISOGRID_SANDBOX` attribute
- For each sandbox face:
- read outer + inner loops
- sample edges to polyline (chord tolerance 0.1 mm)
- fit circles on inner loops when circular
- project 3D points to face-local 2D
- write `geometry_sandbox_n.json` using Python Brain input schema
# --- Create spider elements for each hole ---
for hole in geometry['holes']:
cx, cy = hole['center']
radius = hole['diameter'] / 2.0
#### B) `import_profile.py`
# Create center node
center_node = create_node(fem_part, cx, cy, 0.0)
interface_nodes['hole_centers'].append({
'hole_index': hole['index'],
'node_id': center_node.Label,
'x': cx, 'y': cy
})
- Read `rib_profile_sandbox_n.json`
- Rebuild NX curves from coordinate arrays
- Create/update sheet body for the sandbox zone
- Replace sandbox face geometry while preserving surrounding reserved faces
- Sew/unite resulting geometry into a watertight plate body
# Create circumference nodes
n_circ = max(12, int(math.pi * hole['diameter'] / 2.0)) # ~1 node per 2mm
circ_nodes = []
for j in range(n_circ):
angle = 2 * math.pi * j / n_circ
nx_ = cx + radius * math.cos(angle)
ny_ = cy + radius * math.sin(angle)
node = create_node(fem_part, nx_, ny_, 0.0)
circ_nodes.append(node)
interface_nodes['hole_circumferences'].append({
'hole_index': hole['index'],
'node_id': node.Label,
'x': nx_, 'y': ny_
})
#### C) `solve_and_extract.py`
# Create RBE2 spider (rigid) — default for mounting holes
# Use RBE3 (distributing) for bearing load holes
spider_type = 'RBE2' # could be per-hole from hole table
create_spider(fem_part, center_node, circ_nodes, spider_type)
- Regenerate FE mesh for full plate
- Trigger solve using existing solution object(s)
- Extract from sandbox-associated nodes/elements:
- nodal Von Mises stress
- nodal displacement magnitude
- elemental strain
- total mass
- Write `results.json`:
# --- Create edge BC nodes ---
boundary = geometry['outer_boundary']
edge_spacing = 3.0 # mm between edge nodes
for i in range(len(boundary)):
p1 = boundary[i]
p2 = boundary[(i + 1) % len(boundary)]
edge_length = distance(p1, p2)
n_nodes = max(2, int(edge_length / edge_spacing))
for j in range(n_nodes):
t = j / n_nodes
ex = p1[0] + t * (p2[0] - p1[0])
ey = p1[1] + t * (p2[1] - p1[1])
node = create_node(fem_part, ex, ey, 0.0)
interface_nodes['edge_nodes'].append({
'node_id': node.Label,
'x': ex, 'y': ey
})
# Save interface node map for the iteration script
with open('interface_nodes.json', 'w') as f:
json.dump(interface_nodes, f, indent=2)
return interface_nodes
```json
{
"nodes_xy": [[...], [...]],
"stress_values": [...],
"disp_values": [...],
"strain_values": [...],
"mass": 0.0
}
```
**Step 2 — Apply loads and BCs to Model A:**
### 4.5 Results Extraction Strategy
This is done manually in NX Simcenter (or scripted for standard load cases). The user applies all structural loads and boundary conditions to Model A's center nodes and edge nodes. These never change.
Two output backends are acceptable:
Examples:
- Bolt M8 at hole 3: axial force 5000 N on center node of hole 3
- Fixed constraint at holes 0, 1: fix all DOFs on center nodes of holes 0, 1
- Simply supported edge: constrain Z-displacement on all edge nodes along one plate edge
- Bearing load at hole 7: 2000 N in X-direction via RBE3 at hole 7 center
1. **Direct NXOpen post-processing API** (preferred when available)
2. **Simcenter CSV export + parser** (robust fallback)
**Step 3 — Build dummy Model B and verify:**
Create a simple Model B (e.g., the un-lightweighted plate meshed as shells), set up the assembly FEM with merging, and solve to verify the setup is correct. Compare results against a monolithic (non-assembly) FEA to confirm the spider elements and merging behave as expected.
**Step 4 — Save the template:**
Save Model A, the assembly FEM structure, and the interface node map. This is the reusable template for all optimization iterations.
### 4.3 Per-Iteration NXOpen Journal Script
This is the script that runs inside the optimization loop. It receives the ribbed plate profile from the Python brain and handles Model B rebuild + solve.
```python
# NXOpen iteration script — rebuild Model B, merge, solve, extract
import NXOpen
import json
import numpy as np
def iteration_solve(profile_path, interface_nodes_path, afem_part):
"""
Single optimization iteration:
1. Delete old Model B geometry + mesh
2. Import new profile
3. Mesh with interface node seeds
4. Merge nodes in AFEM
5. Solve
6. Extract results
"""
session = NXOpen.Session.GetSession()
# Load inputs
with open(profile_path) as f:
profile = json.load(f)
with open(interface_nodes_path) as f:
interface_nodes = json.load(f)
if not profile['valid']:
return {'status': 'invalid_geometry', 'mass': float('inf')}
# --- Step 1: Clean old Model B ---
model_b = get_model_b_fem(afem_part)
delete_all_mesh(model_b)
delete_all_geometry(model_b)
# --- Step 2: Import new 2D profile ---
# Create curves from profile coordinate arrays
outer_coords = profile['outer_boundary']
create_closed_polyline(model_b, outer_coords)
for pocket_coords in profile['pockets']:
create_closed_polyline(model_b, pocket_coords)
# Create sheet body from bounded regions
sheet_body = create_sheet_from_curves(model_b)
# --- Step 3: Mesh with interface seeds ---
mesh_control = get_mesh_collector(model_b)
# Add hard-point mesh seeds at all interface locations
# These force the mesher to place nodes exactly where
# Model A's spiders attach
for node_info in interface_nodes['hole_circumferences']:
add_mesh_seed_point(mesh_control, node_info['x'], node_info['y'])
for node_info in interface_nodes['edge_nodes']:
add_mesh_seed_point(mesh_control, node_info['x'], node_info['y'])
# Set mesh parameters
set_element_size(mesh_control, target=2.0, min_size=0.5) # mm
set_element_type(mesh_control, 'CQUAD4') # prefer quads, allow tris
# Generate mesh
mesh_control.GenerateMesh()
# --- Step 4: Merge nodes in Assembly FEM ---
afem = get_assembly_fem(afem_part)
merge_coincident_nodes(afem, tolerance=0.05) # mm
# Verify merge count matches expected
expected_merges = (
len(interface_nodes['hole_circumferences']) +
len(interface_nodes['edge_nodes'])
)
actual_merges = get_merge_count(afem)
if actual_merges < expected_merges * 0.95:
# Merge failed for some nodes — flag as warning
print(f"WARNING: Expected {expected_merges} merges, got {actual_merges}")
# --- Step 5: Solve ---
solution = get_solution(afem, 'static_analysis')
solve_result = solution.Solve()
if not solve_result.success:
return {'status': 'solve_failed', 'mass': float('inf')}
# --- Step 6: Extract results ---
results = extract_results(afem, solution)
return results
def extract_results(afem, solution):
"""
Extract field results from the solved assembly FEM.
Only extracts from Model B elements (the plate mesh),
ignoring Model A's spider elements.
"""
post = get_post_processor(afem)
# Get results only from Model B's element group
model_b_elements = get_model_b_element_group(afem)
# Von Mises stress (nodal, averaged at nodes)
stress_data = post.GetNodalResults(
solution,
result_type='Stress',
component='Von Mises',
element_group=model_b_elements
)
# Displacement magnitude (nodal)
disp_data = post.GetNodalResults(
solution,
result_type='Displacement',
component='Magnitude',
element_group=model_b_elements
)
# Strain (elemental)
strain_data = post.GetElementalResults(
solution,
result_type='Strain',
component='Von Mises',
element_group=model_b_elements
)
# Mass from Model B mesh (plate material only, not spiders)
mass = compute_shell_mass(model_b_elements)
results = {
'status': 'solved',
'mass': mass,
'max_von_mises': float(np.max(stress_data['values'])),
'max_displacement': float(np.max(disp_data['values'])),
'mean_von_mises': float(np.mean(stress_data['values'])),
'stress_field': {
'nodes_xy': stress_data['coordinates'].tolist(),
'values': stress_data['values'].tolist()
},
'displacement_field': {
'nodes_xy': disp_data['coordinates'].tolist(),
'values': disp_data['values'].tolist()
},
'strain_field': {
'elements_xy': strain_data['centroids'].tolist(),
'values': strain_data['values'].tolist()
}
}
return results
```
### 4.4 Why This Approach Is Robust
The AFEM node-merge strategy solves the hardest problem in automated FEA iteration: **load and BC persistence across geometry changes.** Here's why it works reliably:
**Fixed merge locations:** Hole centers, hole circumferences, and plate edges don't move between iterations. The merge is always at the same physical coordinates. NX's node merge by tolerance is a simple, reliable geometric operation.
**Mesh seed enforcement:** By placing hard-point seeds at all interface locations, the mesher is forced to create nodes at exactly those coordinates. This guarantees that every merge finds its partner node.
**Rib pattern agnostic:** Model A doesn't know or care what the rib pattern looks like. It only knows where the holes and edges are. Whether there are 50 or 200 pockets, the spiders connect the same way.
**Easy validation:** After merging, a simple check (did we get the expected number of merged node pairs?) catches any meshing or geometry issues before wasting time on a solve.
**Extensible:** Adding new load cases, new holes, or new BC types only requires modifying Model A (once). The optimization loop and Model B generation are unaffected.
### 4.5 Simcenter Configuration Details
**Shell property (PSHELL):**
- Thickness: from `geometry.json` (e.g., 10.0 mm)
- Material: MAT1 referencing the plate material (e.g., AL6061-T6)
- Applied to all Model B elements
**Spider elements:**
- RBE2 (rigid): 6 DOF coupling from center to circumference nodes. Use for fixed/bolted connections where the hole acts as a rigid interface.
- RBE3 (weighted average): Distributes loads from center to circumference. Use for bearing loads where the hole deforms under load and you want realistic load distribution.
- Choice is per-hole, set during one-time setup based on connection type.
**Mesh controls for Model B:**
- Target element size: 1.53.0 mm (captures rib geometry adequately)
- Minimum element size: 0.5 mm (allows refinement at narrow rib junctions)
- Element type: CQUAD4 dominant with CTRIA3 fill
- Mesh seeds: hard points at all interface node locations
- Edge mesh control on hole circumferences: N elements matching spider node count
**Solution sequences:**
- SOL 101: Static analysis (v1)
- SOL 103: Normal modes / modal analysis (v2, for natural frequency constraints)
- SOL 105: Buckling (v2, for thin-rib stability checks)
Both must produce consistent arrays for downstream optimization and optional stress-feedback loops.
---
@@ -1054,33 +788,32 @@ Build and test the geometry generator independently of NX:
**Deliverable:** A Python module that takes `geometry.json` + parameters → outputs `rib_profile.json` + visualization plots.
### Phase 2 — NX Geometry Extraction + AFEM Setup Scripts (1-2 weeks)
### Phase 2 — NX Sandbox Extraction + Profile Import Scripts (1-2 weeks)
Build the NXOpen scripts for one-time project setup:
Build the NXOpen scripts for reserved-region geometry handling:
- Face selection and hole detection script → exports `geometry.json`
- Hole weight assignment UI (or table import)
- Model A builder: spider elements at all holes + edge BC nodes → exports `interface_nodes.json`
- Assembly FEM creation with Model A + dummy Model B
- Load/BC application to Model A (manual or scripted for standard cases)
- Verification solve on dummy Model B
- Save as reusable template
- Sandbox discovery via NX attribute (`ISOGRID_SANDBOX = sandbox_n`)
- Per-sandbox extraction script → `geometry_sandbox_n.json`
- Local 2D projection + loop sampling (outer + inner loops)
- Rib profile import script (`rib_profile_sandbox_n.json`)
- Sandbox-only geometry replacement + sew/unite with reserved regions
- End-to-end JSON round-trip validation on multi-sandbox plates
**Deliverable:** Complete one-time setup pipeline. Given any plate model, produces the AFEM template ready for optimization.
**Deliverable:** Complete NX geometry round-trip pipeline (extract/import) with reserved regions preserved.
### Phase 3 — NX Iteration Script (1-2 weeks)
### Phase 3 — NX Iteration Solve + Results Extraction (1-2 weeks)
Build the NXOpen journal script for the per-iteration loop:
Build the NXOpen per-iteration analysis script:
- Model B geometry cleanup (delete old mesh + geometry)
- Profile import from `rib_profile.json` → NX curves → sheet body
- Mesh with hard-point seeds at interface node locations
- Assembly node merge with verification
- Nastran solve trigger
- Result extraction (stress/displacement/strain fields + scalar metrics) → `results.json`
- End-to-end test: Python Brain → NX journal → results → validate against manual FEA
- Extract sandbox geometry every iteration (supports moving/optimized holes)
- Import regenerated rib profile into sandbox region(s)
- Remesh the **full** plate as one monolithic model
- Trigger existing Simcenter solution setup
- Extract nodal stress/displacement + elemental strain + mass
- Serialize standardized `results.json` for Atomizer
- End-to-end test: Python Brain → NX scripts`results.json` vs manual benchmark
**Deliverable:** Complete single-iteration pipeline, verified against known-good manual analysis.
**Deliverable:** Production-ready per-iteration NX pipeline with stable result export for optimization.
### Phase 4 — Atomizer Integration (1 week)