forked from 1b-agent/fieldcraft-upstream
solver: nonlinear static analysis by Newton–Raphson with automatic increments
solve.nonlinear follows a nonlinear static step in load increments: dead loads and prescribed displacements ramp with the load factor, a pressure follows the deformed faces (its load stiffness symmetrised so the supernodal Cholesky stays), the consistent tangent is refactored every iteration with an optional line search, and an increment converges on force, displacement and energy together. Increments start from the extrapolated last one, grow after fast convergence and are cut back on inversion, a non-finite or growing residual, an indefinite tangent or too many iterations; the step stops cleanly at the minimum increment, the increment cap or the Newton iteration limit. Elements are assembled in parallel in label order (same bits on any thread count). Results carry Cauchy stress, logarithmic strain, the increment history and a displacement frame per increment, which results.frame and the results panel show. Trusses, shells, beams, plane stress, incompatible modes, temperature and centrifugal loads are refused by name; couplings warn that they stay linear. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm
This commit is contained in:
1 parent
2321d75cc6
commit
2183fdbe81
14 files changed
+1579
-43
No files matched your search
@@ -73,10 +73,15 @@ impl Plot {
|
||||
}
|
||||
}
|
||||
|
||||
/// An explicit or transient heat step's frame shown, its time and the number of frames.
|
||||
/// An explicit or transient heat step's frame shown, its time (a nonlinear static step's:
|
||||
/// its load factor) and the number of frames.
|
||||
pub fn frame(&self) -> Option<(usize, f64, usize)> {
|
||||
let (n, time): (usize, &dyn Fn(usize) -> Option<f64>) = match self.result.kind() {
|
||||
Kind::Explicit(e) => (e.frames.len(), &|k| e.frames.get(k).map(|f| f.time)),
|
||||
Kind::Static(r) if r.nonlinear.is_some() => {
|
||||
let frames = r.nonlinear.as_ref().map(|h| h.frames.as_slice()).unwrap_or_default();
|
||||
(frames.len(), &|k| frames.get(k).map(|f| f.load_factor))
|
||||
}
|
||||
Kind::Heat(h) if h.times.len() > 1 => (h.times.len(), &|k| h.times.get(k).copied()),
|
||||
_ => return None,
|
||||
};
|
||||
@@ -109,6 +114,8 @@ pub fn swing(result: &StepResult, frame: Option<u64>) -> f64 {
|
||||
let a = std::f64::consts::TAU * k as f64 / FRAMES as f64;
|
||||
match result.kind() {
|
||||
Kind::Frequency(_) => a.sin(),
|
||||
// A nonlinear step plays its increments' frames.
|
||||
Kind::Static(r) if r.nonlinear.is_some() => 1.0,
|
||||
Kind::Static(_) => 0.5 * (1.0 - a.cos()),
|
||||
Kind::Explicit(_) | Kind::Fluid(_) | Kind::Heat(_) => 1.0,
|
||||
}
|
||||
@@ -118,10 +125,13 @@ pub fn swing(result: &StepResult, frame: Option<u64>) -> f64 {
|
||||
/// step running through its field frames once per cycle.
|
||||
pub fn pick(view: &ResultsView, result: &StepResult, frame: Option<u64>) -> Pick {
|
||||
let mut p = view.pick();
|
||||
if let (Some(k), Kind::Explicit(e)) = (frame, result.kind())
|
||||
&& let Some(last) = e.frames.len().checked_sub(1)
|
||||
{
|
||||
p.frame = Some((k as usize * e.frames.len() / FRAMES as usize).min(last));
|
||||
let frames = match result.kind() {
|
||||
Kind::Explicit(e) => e.frames.len(),
|
||||
Kind::Static(r) => r.nonlinear.as_ref().map_or(0, |h| h.frames.len()),
|
||||
_ => 0,
|
||||
};
|
||||
if let (Some(k), Some(last)) = (frame, frames.checked_sub(1)) {
|
||||
p.frame = Some((k as usize * frames / FRAMES as usize).min(last));
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
@@ -162,6 +162,17 @@ pub fn controls(app: &mut ModelApp, plot: &Plot, ui: &mut egui::Ui, t: &Tokens)
|
||||
if let Kind::Explicit(e) = plot.result.kind() {
|
||||
ui.separator();
|
||||
explicit(ui, e, plot, t, &mut run);
|
||||
} else if let Some((k, factor, n)) = plot.frame().filter(|_| matches!(plot.result.kind(), Kind::Static(_))) {
|
||||
// A nonlinear static step: its increments, the deformed shape following the slider.
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Increment");
|
||||
let mut frame = k;
|
||||
if ui.add(egui::Slider::new(&mut frame, 0..=n.saturating_sub(1))).changed() {
|
||||
run.push(("results.frame", json!({"frame": frame})));
|
||||
}
|
||||
});
|
||||
ui.label(RichText::new(format!("load factor {}", number(factor))).color(t.text_dim));
|
||||
} else if let Kind::Frequency(f) = plot.result.kind() {
|
||||
ui.separator();
|
||||
ui.label(RichText::new("Modes").color(t.text_dim));
|
||||
|
||||
Reference in new issue
Block a user