diff --git a/src/Lodur.Core/PhysiologyPlan.cs b/src/Lodur.Core/PhysiologyPlan.cs
index 522ac1e..1c3a0e3 100644
--- a/src/Lodur.Core/PhysiologyPlan.cs
+++ b/src/Lodur.Core/PhysiologyPlan.cs
@@ -15,15 +15,28 @@ namespace Lodur
/// What an effect's curve is read at: its affliction's severity or age (in its clock's seconds), or the organism's blood loss.
public enum EffectDriver { Severity, Age, BloodLoss }
+ ///
+ /// The material of a layer simulated as a particle sheet. is the particle spacing in m. The compliances are
+ /// XPBD compliances in m/N: along the sheet's edges (also its joint stitches) and to the bone. is
+ /// ultimate stress in Pa; the sheet builder derives an edge's break force as TensileStrength x Thickness x Spacing.
+ ///
+ public readonly record struct SheetDef(double Spacing, double EdgeCompliance, double AttachCompliance, double TensileStrength);
+
///
/// One tissue layer of a part. , and are
/// function weights, a closed set with one reader each: a capacity is the weighted mean integrity of the tissues that carry its weight.
- /// A Vital tissue at integrity 0 kills.
+ /// A Vital tissue at integrity 0 kills. A stack is shells ( above 0, in m) outside-in, then cores (Thickness 0:
+ /// bone, organs, a muscle with no sheet); the cores fill what the shells leave of the part's shape. is the
+ /// material of a shell simulated as a particle sheet; null means it is not.
///
public readonly record struct TissueDef(
- string Label, double Hp, double Vascularity, bool Vital = false, double Consciousness = 0.0, double BloodPumping = 0.0, double Motor = 0.0);
+ string Label, double Hp, double Vascularity, bool Vital = false, double Consciousness = 0.0, double BloodPumping = 0.0, double Motor = 0.0)
+ {
+ public double Thickness { get; init; }
+ public SheetDef? Sheet { get; init; }
+ }
- /// A part's tissue stack, outside-in, named by the body part's label and side.
+ /// The one tissue stack of a part, outside-in, owned by and joined to a only through .
public readonly record struct PartTissuesDef(string PartLabel, Side Side, IReadOnlyList Tissues);
/// The blood: nominal volume in m^3, the lost fraction that kills, and the regrowth per slow second as a fraction of nominal.
@@ -65,7 +78,7 @@ namespace Lodur
///
/// Physiology as content: tissue stacks per body part, the afflictions that can be bound, the organism-wide effects of blood
- /// loss, the blood and the size of the affliction table. Validated at construction; resolved against a by .
+ /// loss, the blood and the size of the affliction table. Validated at construction; resolved against a by , the one (label, side) join, which and the sheet builder both call.
///
public sealed class PhysiologyPlan
{
@@ -122,6 +135,7 @@ namespace Lodur
foreach (var p in Parts)
{
var seen = new HashSet();
+ var core = false;
foreach (var t in p.Tissues)
{
var where = $"tissue '{t.Label}' of part '{p.PartLabel}' {p.Side}";
@@ -133,6 +147,21 @@ namespace Lodur
{
throw new ArgumentException($"{where}: a function weight is not finite and at least 0.");
}
+
+ if (!(IsFinite(t.Thickness) && t.Thickness >= 0.0)) throw new ArgumentException($"{where}: thickness is not finite and at least 0.");
+ if (t.Thickness == 0.0) core = true;
+ else if (core) throw new ArgumentException($"{where}: a shell follows a core.");
+ if (t.Sheet is SheetDef sh)
+ {
+ if (!(t.Thickness > 0.0)) throw new ArgumentException($"{where}: a sheet needs a thickness above 0.");
+ if (!(IsFinite(sh.Spacing) && sh.Spacing > 0.0)) throw new ArgumentException($"{where}: sheet spacing is not finite and above 0.");
+ if (!(IsFinite(sh.EdgeCompliance) && sh.EdgeCompliance >= 0.0 && IsFinite(sh.AttachCompliance) && sh.AttachCompliance >= 0.0))
+ {
+ throw new ArgumentException($"{where}: a sheet compliance is not finite and at least 0.");
+ }
+
+ if (!(IsFinite(sh.TensileStrength) && sh.TensileStrength > 0.0)) throw new ArgumentException($"{where}: sheet tensile strength is not finite and above 0.");
+ }
}
}
diff --git a/tests/Lodur.Core.Tests/PhysiologyPlanTests.cs b/tests/Lodur.Core.Tests/PhysiologyPlanTests.cs
index c17b1fe..77c7204 100644
--- a/tests/Lodur.Core.Tests/PhysiologyPlanTests.cs
+++ b/tests/Lodur.Core.Tests/PhysiologyPlanTests.cs
@@ -59,6 +59,20 @@ public sealed class PhysiologyPlanTests
Refuses(() => Plan(new[] { t with { BloodPumping = double.NaN } }));
Refuses(() => Plan(new[] { t with { Motor = double.PositiveInfinity } }));
+ var sheet = new SheetDef(0.1, 1e-4, 1e-3, 1e6);
+ var shell = t with { Label = "shell", Thickness = 0.01, Sheet = sheet };
+ Refuses(() => Plan(new[] { t with { Thickness = -1 } }));
+ Refuses(() => Plan(new[] { t with { Thickness = double.NaN } }));
+ Refuses(() => Plan(new[] { t with { Sheet = sheet } })); // a sheet on Thickness 0
+ Refuses(() => Plan(new[] { shell with { Sheet = sheet with { Spacing = 0 } } }));
+ Refuses(() => Plan(new[] { shell with { Sheet = sheet with { Spacing = double.NaN } } }));
+ Refuses(() => Plan(new[] { shell with { Sheet = sheet with { EdgeCompliance = -1 } } }));
+ Refuses(() => Plan(new[] { shell with { Sheet = sheet with { EdgeCompliance = double.NaN } } }));
+ Refuses(() => Plan(new[] { shell with { Sheet = sheet with { AttachCompliance = -1 } } }));
+ Refuses(() => Plan(new[] { shell with { Sheet = sheet with { TensileStrength = 0 } } }));
+ Refuses(() => Plan(new[] { shell with { Sheet = sheet with { TensileStrength = double.NaN } } }));
+ Refuses(() => Plan(new[] { t, shell })); // a shell after a core
+
var a = new AfflictionDef("a", PhysiologyClock.Acute, 0, true, Array.Empty());
Refuses(() => Plan(afflictions: new[] { a, a })); // duplicate affliction label
Refuses(() => Plan(afflictions: new[] { a with { Label = "" } }));
@@ -81,6 +95,16 @@ public sealed class PhysiologyPlanTests
Refuses(() => Plan(slots: 0));
}
+ [Fact]
+ public void A_positional_tissue_has_no_thickness_and_no_sheet_and_zero_compliance_is_accepted()
+ {
+ var t = new TissueDef("t", 10, 1, Consciousness: 1, Motor: 1);
+ Assert.Equal(0.0, t.Thickness);
+ Assert.Null(t.Sheet);
+ Plan(new[] { t });
+ Plan(new[] { t with { Label = "s", Thickness = 0.01, Sheet = new SheetDef(0.1, 0, 0, 1) }, t });
+ }
+
[Fact]
public void An_affliction_may_use_every_driver_and_the_boundary_values_of_the_rules_are_accepted()
{