# hpeuscher/oxygen-concentrator-model architecture

> Architecture diagram of the GitHub repository hpeuscher/oxygen-concentrator-model, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hpeuscher/oxygen-concentrator-model
- Repository: https://github.com/hpeuscher/oxygen-concentrator-model

## Overview

#### Purpose and entry points
This is a MATLAB/Octave simulation repository for a Devilbiss-style pressure-swing adsorption (PSA) oxygen concentrator. The principal executable workflows are:
- `src/sim_devilbiss_theoretical.m` — parameterized theoretical device simulation.
- `src/sim_devilbiss_experimental.m` — simulation aligned with recorded experimental data.
- `src/sim_psa.m` — core PSA-cycle simulation invoked by the device-level workflows.

The included measurement input is `datasets/20260410_122553_Devilbiss.mat`.

#### Device-level simulation orchestration
`src/sim_devilbiss_theoretical.m` and `src/sim_devilbiss_experimental.m` configure a Devilbiss system, establish operating scenarios, run the PSA model, and produce result views. They form the boundary between user-facing study scripts and reusable physical-model functions.

Default model parameters are centralized in `src/devilbiss_default_params.m`, allowing both entry points to share nominal device, bed, valve, and timing assumptions.

#### PSA state evolution
`src/sim_psa.m` is the central dynamic model. It advances the PSA system through its cycle and coordinates pressure, flow, adsorption/state behavior, and boundary-condition inputs. Its output is the primary simulation-result structure consumed by visualization and comparison stages.

Historical or phase-dependent PSA state is supplied by `src/historic_psa_state_devilbiss.m`, which provides Devilbiss-specific state context needed across cycle transitions.

#### Boundary conditions and system interfaces
`src/get_bc_devilbiss.m` defines Devilbiss-specific boundary conditions for the PSA model. This separates external device behavior—such as supply, product, exhaust, or cycle-phase conditions—from generic cycle integration in `src/sim_psa.m`.

This is an important modeling boundary: device scripts select parameters and conditions; the PSA engine evolves the internal system under those conditions.

#### Pneumatic flow modeling
Flow through ordinary restrictions/valves is modeled by `src/compute_valve_flow.m`. One-way/check-valve behavior is handled separately by `src/compute_check_valve_flow.m`.

These functions encapsulate component-level pneumatic constraints, so higher-level PSA logic can request flows without embedding valve equations directly. `src/sigmoid.m` likely supports smooth switching or transition behavior used by the physical/control model.

#### Experimental-data integration
`src/sim_devilbiss_experimental.m` is the data-comparison path and is associated with `datasets/20260410_122553_Devilbiss.mat`. The dataset is a material external input boundary: measured device behavior enters here, while the simulation core remains in `src/sim_psa.m` and its Devilbiss adapters.

#### Results visualization
Simulation outputs are rendered through:
- `src/plot_simulation_results_1d.m`
- `src/plot_simulation_results_2d.m`

`src/link_all_axes.m` supports synchronized figure inspection, and `src/colormap_symmetric.m` supports balanced visualization of signed or centered quantities. Plotting is downstream of simulation and should not alter model state.

Main entry points: [`src/sim_psa.m`](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/sim_psa.m) (PSA cycle simulator), [`src/sim_devilbiss_experimental.m`](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/sim_devilbiss_experimental.m) (Experimental study), [`src/sim_devilbiss_theoretical.m`](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/sim_devilbiss_theoretical.m) (Theoretical study), [`src/plot_simulation_results_2d.m`](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/plot_simulation_results_2d.m) (2D results plots)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflows["Study workflows"]
  node_theoretical["Theoretical study<br/>MATLAB script"]
  node_experimental["Experimental study<br/>MATLAB script"]
  node_dataset[("Devilbiss measurements<br/>MAT dataset")]
end

subgraph group_model["PSA model"]
  node_defaults["Default parameters<br/>MATLAB function"]
  node_psa{{"PSA cycle simulator<br/>MATLAB function<br/>[sim_psa.m]"}}
  node_history["Historical PSA state<br/>MATLAB function"]
  node_boundary["Devilbiss boundary conditions<br/>MATLAB function<br/>[get_bc_devilbiss.m]"]
end

subgraph group_pneumatics["Pneumatic components"]
  node_valve_flow["Valve flow<br/>MATLAB function"]
  node_check_valve_flow["Check-valve flow<br/>MATLAB function"]
  node_sigmoid["Smooth switching<br/>MATLAB function<br/>[sigmoid.m]"]
end

subgraph group_results["Results views"]
  node_results_1d["1D results plots<br/>MATLAB function"]
  node_results_2d["2D results plots<br/>MATLAB function"]
  node_link_axes["Linked axes<br/>MATLAB function<br/>[link_all_axes.m]"]
  node_symmetric_colormap["Symmetric colormap<br/>MATLAB function"]
end

node_theoretical -->|"loads"| node_defaults
node_theoretical -->|"runs"| node_psa
node_theoretical -->|"renders results"| node_results_1d
node_theoretical -->|"renders results"| node_results_2d
node_experimental -->|"loads measurements"| node_dataset
node_experimental -->|"loads"| node_defaults
node_experimental -->|"runs"| node_psa
node_experimental -->|"renders comparison"| node_results_1d
node_experimental -->|"renders comparison"| node_results_2d
node_psa -->|"uses state context"| node_history
node_psa -->|"requests conditions"| node_boundary
node_psa -->|"computes flows"| node_valve_flow
node_psa -->|"computes one-way flows"| node_check_valve_flow
node_psa -.->|"uses smooth transitions"| node_sigmoid
node_results_1d -->|"synchronizes views"| node_link_axes
node_results_2d -->|"synchronizes views"| node_link_axes
node_results_2d -->|"colors centered values"| node_symmetric_colormap

click node_theoretical "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/sim_devilbiss_theoretical.m"
click node_experimental "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/sim_devilbiss_experimental.m"
click node_dataset "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/datasets/20260410_122553_Devilbiss.mat"
click node_defaults "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/devilbiss_default_params.m"
click node_psa "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/sim_psa.m"
click node_history "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/historic_psa_state_devilbiss.m"
click node_boundary "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/get_bc_devilbiss.m"
click node_valve_flow "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/compute_valve_flow.m"
click node_check_valve_flow "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/compute_check_valve_flow.m"
click node_sigmoid "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/sigmoid.m"
click node_results_1d "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/plot_simulation_results_1d.m"
click node_results_2d "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/plot_simulation_results_2d.m"
click node_link_axes "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/link_all_axes.m"
click node_symmetric_colormap "https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/colormap_symmetric.m"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_theoretical,node_experimental,node_dataset toneBlue
class node_defaults,node_psa,node_history,node_boundary toneAmber
class node_valve_flow,node_check_valve_flow,node_sigmoid toneMint
class node_results_1d,node_results_2d,node_link_axes,node_symmetric_colormap toneRose
```

## Components

### Study workflows

User-facing device simulation scripts.

- [Theoretical study](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/sim_devilbiss_theoretical.m): MATLAB script · Parameterized nominal-device simulation. · `src/sim_devilbiss_theoretical.m`
- [Experimental study](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/sim_devilbiss_experimental.m): MATLAB script · Simulation and measured-data comparison workflow. · `src/sim_devilbiss_experimental.m`
- [Devilbiss measurements](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/datasets/20260410_122553_Devilbiss.mat): MAT dataset · Recorded experimental device input. · `datasets/20260410_122553_Devilbiss.mat`

### PSA model

Cycle evolution and Devilbiss-specific model adapters.

- [Default parameters](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/devilbiss_default_params.m): MATLAB function · Shared nominal device, bed, valve, and timing assumptions. · `src/devilbiss_default_params.m`
- [PSA cycle simulator](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/sim_psa.m): MATLAB function · Central dynamic model that advances PSA cycle state. · `src/sim_psa.m`
- [Historical PSA state](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/historic_psa_state_devilbiss.m): MATLAB function · Devilbiss state context across cycle transitions. · `src/historic_psa_state_devilbiss.m`
- [Devilbiss boundary conditions](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/get_bc_devilbiss.m): MATLAB function · Supply, product, exhaust, and phase conditions. · `src/get_bc_devilbiss.m`

### Pneumatic components

Reusable valve-flow constraints.

- [Valve flow](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/compute_valve_flow.m): MATLAB function · Flow through ordinary restrictions and valves. · `src/compute_valve_flow.m`
- [Check-valve flow](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/compute_check_valve_flow.m): MATLAB function · One-way pneumatic flow behavior. · `src/compute_check_valve_flow.m`
- [Smooth switching](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/sigmoid.m): MATLAB function · Supports smooth physical or control transitions. · `src/sigmoid.m`

### Results views

Downstream visualization utilities.

- [1D results plots](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/plot_simulation_results_1d.m): MATLAB function · Renders one-dimensional simulation outputs. · `src/plot_simulation_results_1d.m`
- [2D results plots](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/plot_simulation_results_2d.m): MATLAB function · Renders two-dimensional simulation outputs. · `src/plot_simulation_results_2d.m`
- [Linked axes](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/link_all_axes.m): MATLAB function · Synchronizes figure inspection. · `src/link_all_axes.m`
- [Symmetric colormap](https://github.com/hpeuscher/oxygen-concentrator-model/blob/main/src/colormap_symmetric.m): MATLAB function · Balanced display for signed or centered values. · `src/colormap_symmetric.m`

## Connections

- Theoretical study → Default parameters: loads
- Theoretical study → PSA cycle simulator: runs
- Theoretical study → 1D results plots: renders results
- Theoretical study → 2D results plots: renders results
- Experimental study → Devilbiss measurements: loads measurements
- Experimental study → Default parameters: loads
- Experimental study → PSA cycle simulator: runs
- Experimental study → 1D results plots: renders comparison
- Experimental study → 2D results plots: renders comparison
- PSA cycle simulator → Historical PSA state: uses state context
- PSA cycle simulator → Devilbiss boundary conditions: requests conditions
- PSA cycle simulator → Valve flow: computes flows
- PSA cycle simulator → Check-valve flow: computes one-way flows
- PSA cycle simulator → Smooth switching: uses smooth transitions
- 1D results plots → Linked axes: synchronizes views
- 2D results plots → Linked axes: synchronizes views
- 2D results plots → Symmetric colormap: colors centered values
