Skip to content

Semidefinite Programming, BVP, Continuum Physics & CAD/ECAD ​

Implementation:


Academic Citations ​

Semidefinite Programming & Sum-of-Squares (SOS) ​

  • Vandenberghe, L., & Boyd, S. (1996). "Semidefinite Programming."
    SIAM Review, 38(1), pp. 49–95.
    DOI: 10.1137/1038003
  • Helmberg, C., Rendl, F., Vanderbei, R. J., & Wolkowicz, H. (1996). "An interior-point method for semidefinite programming."
    SIAM Journal on Optimization, 6(2), pp. 342–361.
    DOI: 10.1137/0806018
  • Alizadeh, F., Haeberly, J. P. A., & Overton, M. L. (1998). "Primal-dual interior-point methods for semidefinite programming: convergence rates, stability and numerical results."
    SIAM Journal on Optimization, 8(3), pp. 746–768.
    DOI: 10.1137/S105262349528701X
  • Parrilo, P. A. (2003). "Semidefinite programming relaxations for semialgebraic problems."
    Mathematical Programming, 96(2), pp. 293–320.
    DOI: 10.1007/s10107-003-0387-5 (SOS Programming)

Boundary Value Problems (BVP) & Multiple Shooting ​

  • Morrison, D. D., Riley, J. D., & Zancanaro, J. F. (1962). "Multiple shooting method for two-point boundary value problems."
    Communications of the ACM, 5(12), pp. 613–614.
    DOI: 10.1145/368996.369028
  • Stoer, J., & Bulirsch, R. (2002). Introduction to Numerical Analysis (3rd ed.). Texts in Applied Mathematics 12, Springer. Section 7.3: Multiple Shooting Methods.
    ISBN: 978-0-387-95452-3
  • Ascher, U. M., Mattheij, R. M., & Russell, R. D. (1995). Numerical Solution of Boundary Value Problems for Ordinary Differential Equations.
    SIAM Classics in Applied Mathematics 13.
    DOI: 10.1137/1.9781611971231
  • Betts, J. T. (2010). Practical Methods for Optimal Control and Estimation Using Nonlinear Programming (2nd ed.).
    SIAM Advances in Design and Control 19.
    DOI: 10.1137/1.9780898718577

Constructive Solid Geometry (CSG), Continuum Physics & CAD/ECAD ​

  • Requicha, A. A. (1980). "Representations for rigid solids: Theory, methods, and systems."
    ACM Computing Surveys, 12(4), pp. 437–464.
    DOI: 10.1145/356827.356833
  • Qian, Y. H., d'Humières, D., & Lallemand, P. (1992). "Lattice BGK models for Navier-Stokes equation."
    Europhysics Letters, 17(6), pp. 479–484.
    DOI: 10.1209/0295-5075/17/6/001
  • Bouzidi, M., Firdaouss, M., & Lallemand, P. (2001). "Momentum transfer of a Boltzmann-lattice fluid with boundaries."
    Physics of Fluids, 13(11), pp. 3452–3459.
    DOI: 10.1063/1.1399290
  • Müller, M., & Gross, M. (2004). "Interactive virtual materials."
    Proceedings of Graphics Interface 2004, pp. 239–246. (Corotational Finite Elements)

ModelScript Architectural Rationale ​

  1. Semidefinite Programming (SDP) for Verified Safety: Formal continuous verification of non-linear physical models requires proving that state trajectories x(t) never breach unsafe operating envelopes. Synthesizing polynomial Lyapunov functions V(x)>0 and barrier certificates B(x)≤0 reduces to finding Sum-of-Squares (SOS) decompositions:p(x)=z(x)TQz(x)≥0⟺Q⪰0By implementing a native primal-dual interior-point SDP solver in WebAssembly, ModelScript provides mathematically verified stability proofs directly in the browser and CLI without relying on external monolithic commercial solvers.
  2. Multiple Shooting BVP for Optimal Trajectories: Boundary Value Problems (BVPs) govern optimal trajectory planning, model predictive control (MPC), and periodic limit cycle detection with split boundary conditions:g(y(t0),y(tend),p)=0Standard single shooting suffers from catastrophic numerical instability on stiff or chaotic dynamics. Multiple shooting subdivides the time horizon into M subintervals, guaranteeing numerical stability and fast Newton-Raphson convergence.
  3. Constructive Solid Geometry (CSG) for Multi-Physics 3D Packaging: Lumped-parameter 1D physical models (Modelica) rely on 3D geometric properties (mass, inertia tensor, aerodynamic drag area, hydraulic volume). ModelScript evaluates OpenSCAD models into normalized CSG solid trees (@modelscript/cad), auto-tagging boundary patches (inlet, outlet, wall, symmetry) for downstream OpenCascade B-Rep evaluation, STEP export, and SU2/OpenFOAM CFD meshing.

Mathematical Formulation & Execution Architecture ​

Rendering diagram...

1. Primal-Dual Interior Point SDP Solver ​

Solves standard primal and dual semidefinite programs:

Primal: minX∈Sntr(CX)s.t.tr(AiX)=bi,X⪰0Dual: maxy∈Rm,S∈SnbTys.t.∑i=1myiAi+S=C,S⪰0
  • Central Path Following: Enforces the perturbed complementarity condition XS=μI with barrier parameter μ=tr(XS)n.
  • WASM Linear Algebra: Predictor-corrector search directions (ΔX,Δy,ΔS) are computed using fast in-memory Cholesky factorizations (wasm_gaussian.ts), with backtracking line search to ensure X+αΔX≻0 and S+αΔS≻0.

2. Multiple Shooting BVP Solver ​

Subdivides the horizon [t0,tend] into M subintervals with mesh points t0<t1<⋯<tM=tend:

  • State Trajectory Variables: Introduces free initial conditions sm at each node tm.
  • Subinterval Integration: Integrates forward from tm to tm+1 using adaptive tsit5:y(tm+1;sm,p)
  • Matching Residual System: Solves the (M⋅n+k)×(M⋅n+k) simultaneous nonlinear system:Fm(sm,sm+1)=y(tm+1;sm,p)−sm+1=0,m=0,…,M−1g(s0,sM,p)=0
  • Newton-Raphson Update: Evaluates sensitivity Jacobians along trajectories and solves the block-banded linear system via WASM Gaussian LU elimination.

3. OpenSCAD CSG Engine & CFD Boundary Tagging ​

Transforms procedural CSG trees into boundary-tagged solid geometries:

  • Evaluates transformations (translate, rotate, scale, mirror) and regularized Boolean operators (union, difference, intersection).
  • Decorates faces with CFD boundary tags (tagPatch, BoundaryPatchType: inlet, outlet, wall, symmetry), for handoff to automated SU2 mesh generators.

4. 3D Continuum Physics & B-Rep Meshing (packages/simulate) ​

ModelScript embeds native 3D continuum fluid, structural, and volumetric meshing engines that couple directly to 1D DAE simulations:

  1. WebGPU D3Q19 Lattice Boltzmann Method (LBM) CFD Solver (webgpu-lbm-runner.ts):
    • Discretizes the Boltzmann transport equation over a 19-velocity 3D lattice (D3Q19) stored in a zero-copy Structure-of-Arrays arena (CfdFieldArena) with ping-pong distribution buffers (f0, f1) and WGSL compute shader execution (LBM_D3Q19_WGSL, workgroups 8×8×4):fipost(x,t)=fi(x,t)−ωloc(fi(x,t)−fieq(ρ,u)),fieq=wiρ(1+3(ci⋅u)+92(ci⋅u)2−32∥u∥2)
    • Smagorinsky Subgrid LES Turbulence: Dynamically adapts the local relaxation frequency ωloc=(τ0+ΔτLES)−1 from the non-equilibrium momentum flux tensor Παβneq=∑iciαciβ(fi−fieq).
    • Bouzidi Curved Boundaries & Moving-Wall FSI: Applies sub-cell linear interpolation for curved solid obstacles (δwall<0.5 vs. δwall≥0.5), injects moving-wall momentum Δfi=6wiρ(ci⋅uwall) for two-way aeroelastic FSI, and integrates surface drag forces via momentum exchange.
  2. 3D Tet4/Tet10 Linear/Nonlinear Corotational Elasticity & Thermal FEA Solver (fea-solver.ts):
    • Assembles global sparse stiffness K and consistent mass M matrices in Compressed Sparse Row (CSR) format for 4-node linear (Tet4Element) and 10-node quadratic (Tet10Element) tetrahedra.
    • Corotational Large-Rotation Kinematics: Extracts element rigid-body rotation Re∈SO(3) from the deformation gradient F=e0E0−1 via 6-step Higham polar decomposition iterations Rk+1=12(Rk+Rk−T), rotating local element stiffness blocks Krot=ReKeReT for geometric nonlinearity invariance.
    • Jacobi-Preconditioned Conjugate Gradient (PCG) & Newmark-β Dynamics: Solves static equilibrium Ku=f and Rayleigh-damped transient elastodynamics Mu¨+(αMM+βKK)u˙+Ku=f using unconditional-stability Newmark-β (β=0.25,γ=0.5) time stepping, outputting nodal/element von Mises stresses and yield safety factors.
  3. STEP B-Rep Tetrahedral Mesher & Prismatic Boundary-Layer Extrusion (step-mesher.ts):
    • StepMesher converts ISO 10303-21 STEP B-Rep entities and watertight surface triangulations into volumetric Tet4 / Tet10 meshes (Tet4Mesher), classifies exterior boundary patches (PatchClassifier), extrudes viscous prismatic inflation layers along WALL_BODY surfaces (BoundaryLayerExtruder), evaluates Jacobian/aspect-ratio quality (MeshQualityAnalyzer), and exports ready-to-run CalculiX (*.inp) and SU2 (*.su2) decks.

5. Mechanical Swept-Volume, GD&T Stack-Up & Inverse CAD (packages/cad) ​

  1. Dynamic Swept-Volume Collision & Clearance Envelopes (dynamic-clearance.ts):
    • DynamicClearanceVerifier bridges continuous reachability flowpipes (TrajectoryStepEnclosure[]) into 3D CAD assemblies (Assembly). At each time step, it propagates interval state enclosures [xilo,xihi] through translational Minkowski sums, rotational corner-envelope expansions, and soft-tissue/compliant cavity morphing (volume_radial s=(V/V0)1/3, anisotropic, and modal skinning).
    • Evaluates exact pairwise AABB separation distances (computeAABBDistance) and closest witness points (computeAABBClosestPoints), automatically synthesizing a 3D counterexample CAD assembly at the worst-case collision timestamp t∗ if any clearance rule is violated.
  2. Worst-Case, Statistical RSS & Coupled Thermal-Elastic GD&T Stack-Up (tolerance-stack.ts):
    • ToleranceStackVerifier verifies 1D/3D kinematic assembly gap loops across directional contributors (di∈{+1,−1}) combining bilateral manufacturing tolerances [tiL,tiU], thermal expansion over [Tmin,Tmax] (ΔLth=L0αCTEΔT), and axial elastic deflection under dynamic loads [Fmin,Fmax] (ΔLel=FL0EA):gmin, WC=∑idiL0,i+∑imin(ditiL,ditiU)+Δgth, min+Δgel, min,σRSS=∑i(tiU−tiL6)2
  3. Certified Bi-Directional CAD Parameter Inversion (parameter-inversion.ts):
    • ParameterInversionEngine closes the loop from 1D system optimization back to 3D MCAD source code. Given target mass/inertia constraints (solveLengthForMass, scaleDimensionsForMass) or optimized Modelica parameters, patchMcadSourceCertified verifies candidate dimensions against a multidisciplinary SafeRegionGuard (Psafe box bounds and buckling/stress/clearance predicates) before rewriting the parametric MCAD AST and regenerating STEP geometry.

6. ECAD / PCB Geometry, Autorouting & DRC (packages/cad/src/ecad/) ​

  1. RS-274X Gerber Aperture Evaluation & Excellon Drill Synthesis (gerber.ts):
    • generateManufacturingFiles compiles multi-layer PCBLayout models (TopCopper, BottomCopper, InnerCopper1/2, Top/BottomSilkscreen, Top/BottomSolderMask, BoardOutline) into IPC-compliant RS-274X Gerber (%FSLAX46Y46*%, 10−6 mm integer precision) with deduplicated aperture macros (%ADD10C,...*%, circle/rect/oval pads, 0.1 mm negative-polarity solder mask expansion %IPNEG*%) and Excellon NC drill programs (drill.xln, METRIC,TZ).
  2. Multi-Layer Interactive & Constrained PCB Trace Router (engine/router.ts):
    • PCBRouter (pcb-router.ts / engine/router.ts) implements a multi-layer trace routing engine supporting pad snap-targeting (snapToPad), 90∘ Manhattan (manhattanRoute) and 45∘ octilinear (diagonal45Route: diag=min(|Δx|,|Δy|)) segment constraints, and automatic plated through-hole via insertion (insertVia) on layer transitions.
  3. Euclidean Trace/Pad Clearance Design Rule Checking (engine/drc.ts):
    • runDRC (pcb-drc.ts / engine/drc.ts) executes non-blocking geometric verification across copper layers, checking minimum trace widths, trace-to-trace, trace-to-pad, and pad-to-pad Euclidean clearances (d(p1,p2)−w1+w22≥cmin), via drill and annular ring minimums (router−rdrill≥amin), point-to-segment board-outline polygon distances (minDistToPolygon), and unconnected ratsnest net completeness.

Upstream & Downstream Integration ​

ComponentUpstream DependenciesDownstream Consumers
SdpSolverPolynomial constraints from TheoryCoordinatorFormal Lyapunov barrier certificates, safety proofs
BvpSolverODE dynamics from DaeBuilder, split boundary specsModel predictive control (MPC), trajectory optimization
ScadEvaluator & StepMesherDeclarative .scad & .step B-Rep modelsFeaSolver, WebGPULbmRunner, CalculiX .inp, SU2 .su2
WebGPULbmRunner & FeaSolverStepMesher Tet4/Tet10 meshes, FSI boundary loadsAeroelastic FSI co-simulation, POD reduced-order models
DynamicClearance & ToleranceStackReachability flowpipes, GD&T specs, CAD AssemblyUnifiedVerifier (msx verify), counterexample STEP export
ParameterInversionEngineOptimized 1D Modelica parameters, SafeRegionGuardAutomated MCAD source patching and AOT STEP regeneration
ECAD Gerber / PCBRouter / DRCElectrical netlists, component footprintsRS-274X .gbr & Excellon .xln manufacturing outputs, WebIDE

Open-Core under the GNU AGPL v3 License; Enterprise Edition (ee/) under the ModelScript Enterprise License. • Trademark Policy