Generated banner for Simbiology Build Model
Generated logo for Simbiology Build Model

Simbiology Build Model

MathWorksOfficialCreated by MathWorks

  • Skill
  • Tool integration
  • Science and research
  • BSD-2-Clause
  • No issues found

From the author

Build, modify, and diagram SimBiology models — API reference, helper functions, and layout patterns. Use when constructing or editing models programmatically or visually.
— the description by MathWorks

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a comprehensive set of helper functions and API patterns for constructing and managing SimBiology models within MATLAB. It covers the full lifecycle of model development, from defining compartments, species, and reactions to managing complex diagram layouts. The skill ensures consistent model structure and provides specific guidance for handling visual representations via the Model Builder app, while maintaining compatibility with headless or remote MATLAB environments.

What it does

  • Provides API patterns for defining compartments, species, reactions, and parameters.
  • Includes helper functions for automated diagram layout and positioning.
  • Manages the lifecycle of the SimBiology Model Builder and Analyzer apps.
  • Ensures consistent naming and unit usage across model components.
  • Supports programmatic model construction without requiring a GUI.
  • Offers safe-open patterns for coordinating between model building and analysis.

When to use it

  • When you need to build or modify a biological model programmatically.
  • When you need to generate or adjust a visual diagram for a SimBiology model.
  • When working with .sbproj files that require preserved layout and styling.
  • When you need to ensure consistent parameterization for standard PK models.

Advantages

  • Enables automated, reproducible model construction.
  • Provides robust layout logic to prevent diagram overlaps and crossing lines.
  • Maintains compatibility across desktop, headless, and remote environments.
  • Standardizes the use of modern SimBiology properties and naming conventions.

Usage examples

“Create a new SimBiology model with a central compartment and a drug species.”
The agent will initialize a new model object, add a compartment named 'Central', and add a 'Drug' species with defined initial values using standard API calls.
“Generate a diagram for my existing model and ensure the layout is clean.”
The agent will open the Model Builder, apply automated positioning for compartments and reactions, and run layout validation checks to ensure zero overlaps.

Install

Documentation by MathWorks

Build SimBiology Models

API reference, helper functions, and patterns for building, modifying, and diagramming SimBiology models. Works in all MATLAB environments (desktop, headless, batch, remote). Diagram/layout features require the Model Builder app and are activated only when the user requests visual output.

When to Use

  • Building or modifying SimBiology models (compartments, species, reactions, parameters, rules, events, doses, observables, variants)

  • Opening, saving, or loading models in the Model Builder / Analyzer apps

  • Designing or adjusting diagram layouts

  • Keywords: "build", "create", "modify", "add compartment/species/reaction", "diagram", "layout"

When NOT to Use

  • Simulation and analysis (use simbiology-simulate-model)

  • Parameter fitting, population modeling, NCA (use simbiology-fit-model)

Must-Follow Rules

1. Add helper scripts to the MATLAB path first

Run at the start of every session:

addpath(fullfile('<WORKSPACE_ROOT>', '.claude', 'skills', 'simbiology-build-model', 'scripts'));
disp('Helper scripts added to path.')
2. Only open the Builder when needed

Do NOT open the Model Builder by default. Open it when:

  • The user explicitly requests a diagram, layout, or visual

  • The input is an .sbproj file — use loadViaBuilder to preserve diagram layout/styling (sbioloadproject loses this data)

A model is fully functional without a diagram — it can be simulated, fitted, and analyzed using only the model object on sbioroot.

3. Model construction uses standard SimBiology API

Build models using addcompartment, addspecies, addreaction, etc. directly. This works in all environments: desktop, headless, batch, remote.

model = sbiomodel('MyModel'); disp(model.uuid)
comp = addcompartment(model, 'Central', 1);
addspecies(comp, 'Drug', 100);
addparameter(model, 'ke', 0.1);
rx = addreaction(model, 'Central.Drug -> null');
kl = addkineticlaw(rx, 'MassAction');
kl.ParameterVariableNames = {'ke'};

For standard PK models (1- or 2-compartment with standard dosing and elimination), use references/pk-library-guidance.md as the reference for correct parameterization, naming, and rules. When no diagram is needed, call PKModelDesign directly. When the user requests a diagram, construct the model manually following the same PK library conventions but use addAndPositionCompartment for layout control (see Rule 8b).

4. Write reactions in the biological forward direction

The diagram renders arrows on products and plain lines on reactants (based on the forward direction of the reaction string). Writing a reaction backwards produces incorrect arrows even if the kinetics are equivalent.

% CORRECT — L and R get plain lines, C gets an arrow
addreaction(model, 'cell.L + cell.R <-> cell.C');

% WRONG — same kinetics but L and R get arrows (they're "products" now)
addreaction(model, 'cell.C <-> cell.L + cell.R');

Guidelines:

  • Binding: write A + B -> C (substrates on left, complex on right)

  • Degradation/elimination: write Drug -> null (not null -> Drug)

  • Synthesis: write null -> mRNA (not mRNA -> null)

  • Transport: write Source.Drug -> Dest.Drug (source on left)

5. Always use qualified names for species and reaction-scoped parameters

Always reference species and reaction-scoped parameters by their qualified name. If any of the names are not valid MATLAB variable names, surround them with square brackets before building the qualified name.

  • Species: CompartmentName.SpeciesName (e.g., Central.Drug, Peripheral.[Drug-bound])

  • Reaction-scoped parameters: ReactionName.ParameterName (e.g., Elimination.ke)

Qualification is always exactly one level deep — the immediate parent compartment only. Multi-level paths like Body.Central.Drug are invalid in reaction strings. This is never ambiguous because compartment names must be globally unique across the entire model (SimBiology enforces this regardless of nesting depth). So Central.Drug is always sufficient.

Compartment naming rules:

  • Names must be unique across the entire model — no two compartments can share a name even at different nesting levels

  • If you need hierarchical naming, use underscores: Body_Central (not nested compartments both named Central)

  • Species names must be unique within a compartment but can repeat across different compartments (disambiguated by Compartment.Species)

6. Use modern property names (Value, Units, Constant)

SimBiology objects (species, compartments, parameters) share a unified property interface. Always use the modern names:

ModernDeprecated (do NOT use)Applies to
ValueInitialAmount, Capacityspecies, compartments, parameters
UnitsInitialAmountUnits, CapacityUnits, ValueUnitsspecies, compartments, parameters
ConstantConstantAmount, ConstantCapacity, ConstantValuespecies, compartments, parameters
sp.Value = 100;       % NOT sp.InitialAmount
sp.Units = 'milligram';  % NOT sp.InitialAmountUnits
sp.Constant = false;  % NOT sp.ConstantAmount

comp.Value = 1;       % NOT comp.Capacity
comp.Units = 'liter'; % NOT comp.CapacityUnits
comp.Constant = true; % NOT comp.ConstantCapacity

p.Value = 0.1;        % NOT redundant, but never use p.ValueUnits or p.ConstantValue
p.Units = '1/hour';
p.Constant = true;
7. Close Builder and Analyzer before sbioreset

sbioreset does NOT close these apps, leaving orphaned windows:

try mb = SimBiology.web.desktophandler.getModelBuilder();
    if ~isempty(mb) && isfield(mb,'webWindow') && isvalid(mb.webWindow), mb.webWindow.close(); end
catch, end
try ma = SimBiology.web.desktophandler.getModelAnalyzer();
    if ~isempty(ma) && isfield(ma,'webWindow') && isvalid(ma.webWindow), ma.webWindow.close(); end
catch, end
pause(1); sbioreset;
8. Diagram rules (only when user requests a diagram)

The following rules apply ONLY when the user asks for a diagram or layout. Skip all of these for pure model construction.

Model size limit (precondition): Layout helpers bail out above 400 total blocks (species + reactions). For large models, skip automated layout — use simple grid positioning instead (reactions at midpoints of connected species).

a. Use addAndPositionCompartment for diagram layout

When building a diagram, use addAndPositionCompartment instead of raw addcompartment + setBlock — it atomically creates, positions, and validates each compartment.

% speciesInfo: cell array of structs with .Name, .Value, .Position
speciesInfo = {
    struct('Name', 'Drug', 'Value', 100, 'Position', [40, 30, 50, 16]);
    struct('Name', 'DrugBound', 'Value', 0, 'Position', [140, 30, 100, 16])
};
[comp, sp] = addAndPositionCompartment(model, 'Central', 1, [20, 20, 280, 80], speciesInfo);
% sp is a SimBiology Species ARRAY — index with sp(1), sp(2), NOT sp{1}

b. Diagram build order

  1. Open the Builder first — the diagram does not exist until the Builder creates it. All simbio.diagram.* calls and addAndPositionCompartment will fail without this step.

  2. Plan [x y w h] positions for ALL compartments up front (leave 80 px gaps minimum)

  3. Build ONE compartment at a time with addAndPositionCompartment

  4. Add ALL parameters (including rule LHS targets), reactions, rules, doses, events

  5. repositionAllReactions(model) then checkDiagramLayout(model) — fix until zero violations

  6. positionAncillaryBlocks(model) — positions rule/parameter blocks in a grid to the right

c. Leave 80 px gaps between connected compartments

Inter-compartment reaction nodes (15×15) are placed in these gaps by repositionAllReactions. Without adequate gaps, reaction lines cross through compartment blocks. For compartments with many shared reactions (3+), increase to 120 px.

d. Post-placement validation is mandatory

After placing all blocks:

repositionAllReactions(model);
results = checkDiagramLayout(model);
if results.nTotal > 0
    for i = 1:numel(model.Reactions)
        pos = computeSafeReactionPosition(model, model.Reactions(i));
        simbio.diagram.setBlock(model.Reactions(i), 'Position', pos);
    end
    results = checkDiagramLayout(model);
end
positionAncillaryBlocks(model);  % must run LAST, after all objects exist

e. Always use the safe-open pattern for the Builder

Never call simBiologyModelBuilder(model) without first checking isAppOpen('builder'). If open, close it, wait 2s, then reopen.

if isAppOpen('builder')
    try
        mb = SimBiology.web.desktophandler.getModelBuilder();
        if ~isempty(mb) && isfield(mb, 'webWindow') && isvalid(mb.webWindow)
            mb.webWindow.close();
        end
    catch, end
    pause(2);
end
% If Analyzer is open, it already has a model loaded — open Builder
% without an argument so it picks up the Analyzer's active model.
% Passing a model argument when Analyzer is open can cause conflicts.
if isAppOpen('analyzer')
    simBiologyModelBuilder();
else
    simBiologyModelBuilder(model);
end

f. Never close the Builder to make modifications

The model handle is on sbioroot — all code works on the live model and updates the diagram in real time. Only close when the user explicitly asks.

Helper Functions (scripts/)

Model construction (always available)
FunctionSignaturePurpose
getModelByUUIDmodel = getModelByUUID(uuid)Look up model by UUID
Diagram & Builder (only when user requests diagram/layout)
FunctionSignaturePurpose
addAndPositionCompartment[comp,sp] = addAndPositionCompartment(model,name,cap,compPos,speciesInfo,Name=Value)Create compartment + species and position atomically. sp is a Species array — index with sp(1), NOT sp{1}. Options: FontWeight ("bold"), TextLocation ("center"), Padding (20), AutoExpand (true), AutoFixPositions (true)
checkDiagramLayoutresults = checkDiagramLayout(model)Containment + line-through-block + overlap checks
computeSafeReactionPositionpos = computeSafeReactionPosition(model,rxn)Crossing-free reaction node position
repositionAllReactionsnFixed = repositionAllReactions(model)Batch-reposition all reactions (up to 3 passes)
positionAncillaryBlocksn = positionAncillaryBlocks(model)Grid-position rule/parameter blocks to the right of compartments
openLiveBuilderopenLiveBuilder(model)Open Builder with safe-open pattern
isAppOpentf = isAppOpen(appName)Check if Builder/Analyzer is open
loadViaBuildermodel = loadViaBuilder(filePath)Load .sbproj preserving diagram
saveViaBuildersaveViaBuilder(filePath)Save from Builder preserving diagram
lineIntersectsRecthit = lineIntersectsRect(x1,y1,x2,y2,rect)Shared geometry helper (used internally by layout scripts)
checkDiagramLayout output
results.nTotal        % total violations (must be 0 before presenting)
results.nContainment  % species outside parent compartment
results.nLineThrough  % connection lines through unrelated blocks
results.nOverlap      % blocks <10px apart

API Quick Reference

Model
  • sbiomodel(name) — create model; model.uuid — unique ID

  • sbioloadproject('file.sbproj') — returns a struct with the model name as field; extract dynamically:

    proj = sbioloadproject('file.sbproj');
    fn = fieldnames(proj);
    model = proj.(fn{1});
  • copyobj(model) — deep clone (does NOT copy diagram layout); verify(model) — check consistency

  • sbioreset — clear all models (close apps first!)

Compartments
  • addcompartment(model, name, value)

  • comp.Value, comp.Constant, comp.Units, model.Compartments

  • Units consistency: If any component has units, ALL components must have units (compartments, species, parameters). Missing units cause 'Dimensional analysis failed' errors at simulation/fit time.

Species
  • addspecies(comp, name, value)

  • sp.Value, sp.Units, sp.BoundaryCondition, sp.Constant

  • sp.Parent.Name — parent compartment; model.Species

Parameters
  • addparameter(model, name, value) — model-scoped

  • addparameter(kineticLaw, name, value) — reaction-scoped

  • p.Value, p.Units, p.Constant, model.Parameters

Reactions
  • addreaction(model, 'A -> B') — forward; 'A <-> B' — reversible

  • kl = addkineticlaw(rx, 'MassAction'); kl.ParameterVariableNames = {'k1'} (or {'kf','kr'} for reversible)

  • Multi-compartment: 'Central.Drug -> Peripheral.Drug'

Rules, Events, Doses
  • addrule(model, 'x = expr', ruleType) — 'initialAssignment', 'repeatedAssignment', 'rate'

  • Rule/reaction exclusivity: A species that is the LHS of a rate rule or repeated assignment rule cannot also appear as a reactant or product in a reaction. Use one or the other to govern its dynamics.

  • Rule LHS requirement: The LHS must be an existing species, parameter, or compartment with Constant = false. Create the parameter before the rule (not after as a fix — this ensures diagram blocks exist for layout):

    p = addparameter(model, 'RO', 0); p.Constant = false;
    addrule(model, 'RO = Complex / (Target + Complex)', 'repeatedAssignment');
  • addevent(model, 'trigger', {'action1', 'action2'})

  • Event action requirement: Any parameter modified in an event action must have Constant = false (parameters default to true):

    p = sbioselect(model, 'Type', 'parameter', 'Name', 'kgrow');
    p.Constant = false;
    addevent(model, 'Tumor.Cancer < 1e6', {'kgrow = kgrow * 0.5'});
  • sbiodose(name, 'schedule') / sbiodose(name, 'repeat')

  • Schedule: .TargetName, .Amount, .Time, .Rate

  • Repeat: .TargetName, .Amount, .StartTime, .Interval, .RepeatCount

  • adddose(model, d) / removedose(model, d)

Observables & Variants
  • addobservable(model, name, expression) — use ./ and .* for element-wise ops

  • StatesToLog caveat: If the observable references a constant parameter (e.g., 'Drug ./ Vd'), add that parameter to StatesToLog — otherwise it logs as NaN. Observables themselves are auto-logged when their dependencies are present (do NOT add observables to StatesToLog — it only accepts species, parameters, and compartments).

  • v = addvariant(model, name) then addcontent(v, {'type','name','prop',val})

  • v.Content, getvariant(model, name)

Simulation Config
  • cs = getconfigset(model, 'active')

  • cs.StopTime, cs.SolverType ('ode15s', 'ode45', 'sundials')

  • cs.RuntimeOptions.StatesToLog — 'all' or handle array

Selection
  • sbioselect(model, 'Type', type, 'Name', name)

  • For reactions: use 'Reaction' property (not 'Name')

Core Patterns

Model creation (standard — no diagram)
model = sbiomodel('MyModel');
disp(model.uuid)
comp = addcompartment(model, 'Central', 1);
addspecies(comp, 'Drug', 100);
addparameter(model, 'ke', 0.1);
Reactions
% MassAction (always use qualified species names)
rx = addreaction(model, 'Central.Drug -> null');
kl = addkineticlaw(rx, 'MassAction');
kl.ParameterVariableNames = {'ke'};

% Custom rate
rx = addreaction(model, 'Central.E + Central.S <-> Central.ES');
rx.ReactionRate = 'kf*Central.E*Central.S - kr*Central.ES';

% Multi-compartment transfer
rx = addreaction(model, 'Central.Drug -> Peripheral.Drug');

% Species with invalid MATLAB variable names
rx = addreaction(model, 'Central.[Drug-bound] -> Central.[Drug-free]');
Removing components
delete(sbioselect(model, 'Type', 'species', 'Name', 'Drug'));
delete(sbioselect(model, 'Type', 'reaction', 'Reaction', 'Drug -> null'));
removedose(model, model.Doses(1));  % doses use removedose, not delete
Doses
% Bolus
d = sbiodose('Dose', 'schedule');
d.TargetName = 'Drug'; d.Amount = 100; d.Time = 0;
adddose(model, d);

% Repeat dose
d = sbiodose('RepeatDose', 'repeat');
d.TargetName = 'Drug'; d.Amount = 50;
d.StartTime = 0; d.Interval = 8; d.RepeatCount = 3;
adddose(model, d);
Events, variants, observables
% Event modifying a parameter — mark non-constant first
p = sbioselect(model, 'Type', 'parameter', 'Name', 'ke');
p.Constant = false;
ev = addevent(model, 'time >= 10', {'ke = ke * 2'}); ev.Name = 'EnzymeInduction';

% Event modifying a species (species default Constant=false — no extra step)
ev = addevent(model, 'time >= 10', {'Drug = 50'}); ev.Name = 'RescueDose';

v = addvariant(model, 'HighDose'); addcontent(v, {'parameter','ke','Value',0.5});
obs = addobservable(model, 'DrugConc', 'Drug ./ Central');

Saving Models

  • Standard: save('mymodel.mat', 'model') / loaded = load('mymodel.mat'); model = loaded.model; Do NOT use sbiosaveproject (deprecated, requires base workspace hacks).

  • With diagram (.sbproj): saveViaBuilder('name.sbproj') / loadViaBuilder(path) (requires Builder open)

  • Switching models: ask user to save first → close Builder → pause(2) → simBiologyModelBuilder(newModel)

  • See references/app-lifecycle-guidance.md for full switching/coordination patterns.

Diagram Basics (only when user requests diagram/layout)

Coordinate system

Position = [x y width height] where (x, y) is top-left corner.

Standard block sizes
Block TypeDefault SizeNotes
Species[50, 16]Scale width: <=5 chars → 50, 6-12 → 100, 13+ → 130
Reaction[15, 15]
Rule[20, 20]
Compartment sizing from content
Species CountSizeNotes
1160 x 100Single species, centered
2 (isolated)240 x 170Vertically stacked
2 (in chain)400 x 100Side by side
3-5160+n*50 x 100+n*35Scale to content
6+240+n*50 x 220+n*35Row layout, multiple rows if needed

Internal padding: 30 px minimum on all sides.

Row-based species placement (3+ species)

Distribute species evenly in a horizontal row at y + height/2 - 8, with 40 px margin from compartment edges. Scale species width by name length: <=5 chars → 50, 6-12 → 100, 13+ → 130.

Species ordering by connection direction

When a compartment has 2+ species that connect to different external compartments, order them so each species faces its connections. This prevents connection lines from crossing through sibling species.

  • Horizontal neighbors: place the species connecting LEFT on the left edge, species connecting RIGHT on the right edge.

  • Vertical stacking: place the species connecting UP/LEFT on top, the species connecting DOWN/RIGHT on bottom.

  • Example: Blood has Neutrophil (connects left to Transit3) and Lymphocyte (connects upper-left to Spleen). Put Lymphocyte on top and Neutrophil on bottom so lines don't cross.

Layout rules

Hard requirements:

  1. No block overlap (except species inside compartments)

  2. Labels visible — not overlapping other blocks

  3. Horizontal/vertical alignment for same-tier compartments

  4. Inter-compartment reactions outside both compartments (in the gap)

  5. No connection lines through unrelated blocks

  6. 50 px minimum reaction-to-species distance

Preferred placement: 7. Elimination/degradation reactions inside their parent compartment (communicates the process occurs locally, not across a boundary)

Flow direction by model type
Model TypeFlow Direction
PKPDPD upper-left, PK lower-right
MetabolicTop-to-bottom
PBPKCirculation-based columns
Simple PKLeft-to-right or diagonal

References

Load on demand for detailed guidance:

  • references/layout-strategy-guidance.md — strategy selection, pre-build checklist, 7 recipes

  • references/pbpk-layout-guidance.md — PBPK circulation and ACAT chain layouts

  • references/evacuation-procedure-guidance.md — 5-phase rearrangement for existing models

  • references/api-cheatsheet-guidance.md — full simbio.diagram API (getBlock, setBlock, lines, clones)

  • references/app-lifecycle-guidance.md — switching models, Analyzer coordination

  • references/diagram-styling-guidance.md — colors, fonts, cloning mechanics

  • references/pk-library-guidance.md — PKModelDesign for standard PK models


Copyright 2026 The MathWorks, Inc.


Files

references/pbpk-layout-guidance.md

PBPK Layout Guidance

Detailed layout recipes for PBPK models, including whole-body circulation layouts and ACAT GI absorption chains. Load this reference when building or modifying PBPK models with diagram layouts.


Recipe F: PBPK Model (Circulation-Based Layout)

PBPK models have a distinctive physiological structure: blood circulates through a closed loop of organ compartments, drug is absorbed from the GI tract, distributed to organs, metabolized, and eliminated. The layout uses a left-to-right column orientation following the drug's path through the body.

Structural subsystems in a PBPK model
SubsystemTypical compartmentsRole
Blood vesselsVenous, ArterialCirculation boundaries
PulmonaryLungVenous -> Arterial bridge
Hepatic / portalLiver, Portal Vein, SpleenFirst-pass metabolism
GI / ACATStomach, Duodenum, Jejunum, Ileum, ColonDrug absorption
Peripheral organsHeart, Brain, Muscle, Kidney, Skin, etc.Tissue distribution
EliminationUrine/Bladder, BileDrug removal
ObservablesCalculations, Plasma, DoseDerived quantities
Column Layout (left to right)
Col 1         Col 2        Col 3     Col 4      Col 5      Col 6
ACAT        -> PV/Spleen -> Liver  -> |Venous|   Organs    |Arterial|
(stacked)                             | bar  |  (stacked)  |  bar   |
                                      |      |             |        |
                                           [Lung] (top, bridging bars)
ColumnContentsx offsetWidthNotes
1ACAT segments20360Vertical stack, 80 px gaps
2PortalVein, Spleen+100 gap130Stacked vertically
3Liver+100 gap120Single compartment
4Venous+100 gap70Tall vertical bar
5Peripheral organs+100 gap120Vertical stack, 60 px gaps
6Arterial+100 gap70Tall vertical bar
topLungcentered120Bridges Venous <-> Arterial

Critical rule: Organs sit BETWEEN the blood vessel bars. Venous is on the left of the organ stack, Arterial on the right. This ensures Organ->Venous outflow lines go left (short) and Arterial->Organ inflow lines come from the right (short). Placing organs outside the bars forces return lines to cross through a blood vessel — always wrong.

Blood vessel bars

Venous and Arterial are drawn as tall narrow vertical bars (70 px wide) that span the full height of the organ stack. This makes them visually distinct as circulation boundaries and provides a clear bus that all organ connections attach to.

  • Bar height = organ stack total height (n organs x 100 + (n-1) x 60)

  • Bar top y = first organ top y

  • Species block centered vertically within the bar, 50 x 16

Organ stack

Peripheral organs are stacked vertically between the blood vessel bars. Each organ is 160 x 100 with a single centered Drug species (50 x 16). Stack with 60 px vertical gaps.

  • Organ->Venous reaction: in the gap between organ left edge and Venous right edge, y-aligned with the organ species

  • Arterial->Organ reaction: in the gap between Arterial left edge and organ right edge, y-aligned with the organ species

  • Stagger inflow/outflow reaction y by +/-12 px to prevent line crossings

Hepatic sub-loop

Liver, PortalVein, and Spleen form a compact group in columns 2-3:

  • PortalVein and Spleen stack vertically in column 2

  • Liver sits in column 3, horizontally aligned with PortalVein

  • PV->Liver reaction in the gap between them

  • Liver->Venous reaction in the gap between Liver and Venous bar

  • Arterial->Liver reaction in the same gap, vertically offset

  • Liver is NOT a peripheral organ — never place it in the organ stack

Lung

Lung sits at the top of the diagram, horizontally centered between the Venous and Arterial bars. It bridges the circulation loop: Venous -> Lung -> Arterial. Place reaction nodes between Lung and their respective bars.

ACAT GI chain

ACAT segments stack vertically in column 1. Each segment contains Drug_unreleased and Drug_dissolved side by side horizontally (not stacked vertically). Absorption reactions go right from dissolved species into PortalVein. See Recipe G below for full details.

PBPK color assignments
SubsystemColorCompartments
Blood / CirculationLight purpleVenous, Arterial, Lung
Peripheral organsLight blueHeart, Brain, Muscle, Kidney, etc.
Hepatic sub-loopLight greenLiver, PortalVein, Spleen
GI / ACAT chainLight orangeStomach, Duodenum, Jejunum, etc.

Recipe G: ACAT GI Absorption Chain (Detailed)

This recipe provides concrete sizing and positioning rules for ACAT GI absorption segments.

Why side-by-side species (not vertical stacking)

ACAT segments connect sequentially: each segment's Drug_unreleased and Drug_dissolved transit to the next segment's corresponding species. If species are stacked vertically, the inter-segment transit lines must cross the other species in the compartment — this is unavoidable and creates line-through-block violations in every gap.

Placing species side by side horizontally gives each species its own vertical column. Transit lines stay within their column and never cross the other species.

WRONG (vertical stacking):        CORRECT (side by side):

+-----------------+                +-------------------------------+
| Drug_unreleased |                | Drug_unreleased Drug_dissolved |
| Drug_dissolved  |                +-------------------------------+
+-----------------+                       |              |
       | X lines cross                    |              |
+-----------------+                +-------------------------------+
| Drug_unreleased |                | Drug_unreleased Drug_dissolved |
| Drug_dissolved  |                +-------------------------------+
+-----------------+
Compartment sizing
PropertyValueNotes
Width400Fits two 130 px species + padding + gap
Height100Single row of species with breathing room
Vertical gap80Between adjacent segments
Species width130Both names are 14-15 chars (>= 13 rule)
Species height16Standard
Species placement within each segment
+---------------------------------------------------+
| <-15px-> [Drug_unreleased 130x16] <-30px-> [Drug_dissolved 130x16] <-15px-> |
|        x=comp_x+15                       x=comp_x+215                       |
|        y=comp_y+comp_h/2-8               y=comp_y+comp_h/2-8                |
+---------------------------------------------------+
          comp_w = 360, comp_h = 80

Both species share the same y-coordinate (vertically centered in the compartment). The 40 px horizontal gap between them leaves room for the dissolution reaction node.

Reaction placement
Reaction typePosition
Dissolution (intra-comp)Between the two species: x=comp_x+193-7, y=comp_y+33
Unreleased transit (inter-comp)In vertical gap, aligned with unreleased column: x=unreleased_cx-7
Dissolved transit (inter-comp)In vertical gap, aligned with dissolved column: x=dissolved_cx-7
Absorption (dissolved->PV)In horizontal gap between ACAT right edge and PV left edge, y-aligned with dissolved species
Fecal elimination (Colon->null)Below Colon, one per column (unreleased column and dissolved column)

Key rule: Transit reaction nodes must be x-aligned with their species column so that connection lines run vertically and never cross the other species.

Positioning formula (5 standard ACAT segments)
acatX = 20;  acatW = 400;  acatH = 100;  acatGap = 80;
segNames = {'Stomach','Duodenum','Jejunum','Ileum','Colon'};

for i = 1:5
    y = 50 + (i-1)*(acatH + acatGap);  % segment top y

    % Compartment
    simbio.diagram.setBlock(comp, 'Position', [acatX y acatW acatH]);

    % Drug_unreleased: left side, 130x16
    simbio.diagram.setBlock(sp_unr, 'Position', [acatX+15, y+acatH/2-8, 130, 16]);

    % Drug_dissolved: right side, 130x16
    simbio.diagram.setBlock(sp_dis, 'Position', [acatX+215, y+acatH/2-8, 130, 16]);
end
Complete ACAT example positions (for acatX=20)
SegmentComp positionDrug_unreleasedDrug_dissolved
Stomach[20 50 360 80][35 82 130 16][235 82 130 16]
Duodenum[20 180 360 80][35 212 130 16][235 212 130 16]
Jejunum[20 310 360 80][35 342 130 16][235 342 130 16]
Ileum[20 440 360 80][35 472 130 16][235 472 130 16]
Colon[20 570 360 80][35 602 130 16][235 602 130 16]
Two-species compartments (side-by-side arrangement)

For compartments in sequential chains where both species transit:

  • Compartment size: 360 x 80

  • Species width: 130 x 16 (both names typically 13+ chars)

  • Drug_unreleased: [comp_x+15, comp_y+comp_h/2-8, 130, 16] (left)

  • Drug_dissolved: [comp_x+215, comp_y+comp_h/2-8, 130, 16] (right)

  • Dissolution reaction node between them: [comp_x+186, comp_y+33, 15, 15]

  • Transit reactions in vertical gaps must be x-aligned with their species column to prevent line crossings


Copyright 2026 The MathWorks, Inc.


Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Node.js

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
MathWorks
Publisher
MathWorks (Official)
Source
matlab/matlab-agentic-toolkit · skills-catalog/computational-biology/simbiology-build-model · commit 2a7f215
Licence
BSD 2-Clause License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE.md)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by MathWorks or MathWorks.

Get it from the source

14 of this skill’s files are not mirrored here, so there is no ZIP. Get the complete skill from its source: matlab/matlab-agentic-toolkit