Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Build (Windows)

on:
push:
branches: [ "master", "main" ]
pull_request:
branches: [ "master", "main" ]
workflow_dispatch:

jobs:
build:
# Guard: if this workflow ever gets merged upstream (e.g. HoareLea),
# it will show as "skipped" there and won't break their CI.
if: github.repository_owner == 'SAM-BIM'
runs-on: windows-2022

env:
MSBUILDDISABLENODEREUSE: "1"
ORG_NAME: "SAM-BIM"
# >>> CHANGE THIS PER REPO <<<
# Examples: SAM, SAM_gbXML, SAM_GEM, SAM_Tas, ...
REPO_NAME: "SAM_Validation"

steps:
- name: Checkout this repo
uses: actions/checkout@v4
with:
fetch-depth: 0
path: ${{ env.REPO_NAME }}

- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Clone dependency repos (siblings)
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'

$org = '${{ env.ORG_NAME }}'
$repo = '${{ env.REPO_NAME }}'

# >>> ADJUST BUILD ORDER HERE IF NEEDED <<<
# Keep the current repo LAST.
$buildOrder = @(
'SAM'
'SAM_Mollier'
'SAM_IAPWS'
$repo
)

# Clone everything except the last one (already checked out by Actions)
$deps = $buildOrder[0..($buildOrder.Count-2)]
foreach ($r in $deps) {
if (Test-Path $r) { continue }
Write-Host "Cloning https://github.com/$org/$r.git"
git clone --depth 1 "https://github.com/$org/$r.git" $r
}

# Ensure ReferencePath exists even before SAM_Windows builds
New-Item -ItemType Directory -Force -Path "SAM_Windows\build" | Out-Null

- name: Restore + Rebuild in order (CI props like SAM_Deploy)
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'

$repo = '${{ env.REPO_NAME }}'
$windowsRef = (Resolve-Path 'SAM_Windows\build').Path

# IMPORTANT: keep these as an ARRAY of args (do NOT join into one string)
$common = @(
'/m:1'
'/nr:false'
'/v:m'
'/p:Configuration=Release'
'/p:UseSharedCompilation=false'
'/p:RunPostBuildEvent=OnOutputUpdated'
"/p:ReferencePath=$windowsRef"
)

# If you really want Platform, use QUOTED Any CPU:
# $common += '/p:Platform="Any CPU"'

# Same build order as above (keep repo LAST)
$buildOrder = @(
'SAM'
'SAM_Mollier'
'SAM_IAPWS'
$repo
)

# Convert build order -> solution paths (robust: first .sln in each folder)
$solutions = foreach ($r in $buildOrder) {
$sln = Get-ChildItem -Path $r -Filter *.sln -File | Select-Object -First 1
if (-not $sln) { throw "No .sln found under: $r" }
$sln.FullName
}

foreach ($sln in $solutions) {
Write-Host "==> Restore: $sln"
& msbuild $sln /t:Restore @common
}

foreach ($sln in $solutions) {
Write-Host "==> Rebuild: $sln"
& msbuild $sln /t:Rebuild @common
}

- name: Upload build folders (optional)
uses: actions/upload-artifact@v4
with:
name: ${{ env.REPO_NAME }}-build-folders
path: |
**\build\*
if-no-files-found: warn
45 changes: 45 additions & 0 deletions .github/workflows/spdx-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: SPDX + Copyright header check

on:
pull_request:

jobs:
spdx:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check header in changed .cs files
run: |
set -e
BASE="${{ github.event.pull_request.base.sha }}"
HEAD="${{ github.event.pull_request.head.sha }}"

FILES=$(git diff --name-only "$BASE" "$HEAD" -- '*.cs' || true)

if [ -z "$FILES" ]; then
echo "No C# files changed."
exit 0
fi

MISSING=""
for f in $FILES; do
HEADBLOCK=$(head -n 6 "$f")

echo "$HEADBLOCK" | grep -q "// SPDX-License-Identifier: LGPL-3.0-or-later" || MISSING="$MISSING $f"
echo "$HEADBLOCK" | grep -q "// Copyright (c) 2020–2025 Michal Dengusiak & Jakub Ziolkowski and contributors" || MISSING="$MISSING $f"
done

if [ -n "$MISSING" ]; then
echo "❌ Missing required header in:"
for f in $MISSING; do echo " - $f"; done
echo ""
echo "Each changed .cs file must start with:"
echo "// SPDX-License-Identifier: LGPL-3.0-or-later"
echo "// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors"
exit 1
fi

echo "✅ SPDX + copyright headers OK."
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Run SAM validation tests
on:
push:
branches: [ main ]
pull_request:

jobs:
build:
Expand Down
2 changes: 2 additions & 0 deletions COPYRIGHT_HEADER.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors
19 changes: 19 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
SAM-BIM — Sustainable Analytical Model (SAM)

Copyright © 2020–2026
Michal Dengusiak & Jakub Ziolkowski and contributors

This repository is part of the SAM (Sustainable Analytical Model) toolkit.

License
This project is licensed under the GNU Lesser General Public License
v3.0 or later (LGPL-3.0-or-later). See the LICENSE file for details.

Attribution and third-party software
Each contributor retains copyright to their respective contributions.
The project history (Git) records authorship and provenance of all changes.

This repository may include or depend on third-party open-source components.
Where applicable, third-party notices and license information are provided in:
- THIRD_PARTY.md (if present)
- LICENSE (and any license files within third-party source folders)
100 changes: 41 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
# SAM_Validation
[![Build](https://github.com/SAM-BIM/SAM_Validation/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/SAM-BIM/SAM_Validation/actions/workflows/build.yml)
[![Installer (latest)](https://img.shields.io/github/v/release/SAM-BIM/SAM_Deploy?label=installer)](https://github.com/SAM-BIM/SAM_Deploy/releases/latest)

<a href="https://github.com/HoareLea/SAM_Validation"><img src="https://github.com/HoareLea/SAM/blob/master/Grasshopper/SAM.Core.Grasshopper/Resources/SAM_Small.png" align="left" hspace="10" vspace="6"></a>
# SAM_Validation

**SAM_Validation** is a repository containing validation tests for various SAM toolkits. Welcome and let's make the opensource journey continue. :handshake:
<a href="https://github.com/SAM-BIM/SAM">
<img src="https://github.com/SAM-BIM/SAM/blob/master/Grasshopper/SAM.Core.Grasshopper/Resources/SAM_Small.png"
align="left" hspace="10" vspace="6">
</a>

# SAM_Validation
**SAM_Validation** is part of the **SAM (Sustainable Analytical Model) Toolkit** —
an open-source collection of tools designed to help engineers create, manage,
and process analytical building models for energy and environmental analysis.

🧪 A modular validation suite for the Sustainable Analytical Model (SAM) platform developed by Hoare Lea.
This repository compares outputs from SAM modules against trusted reference implementations such as PsychroLib and IAPWS-IF97 to ensure numerical correctness, thermodynamic validity, and regression stability.
This repository provides a **modular validation and regression test suite**
used to verify the numerical correctness, physical consistency, and long-term stability
of SAM core modules against trusted reference implementations.

---

## ✅ Purpose
## Purpose

This repository helps verify the physical and numerical accuracy of core SAM components, such as:
The validation framework supports verification of SAM components such as:

- `SAM_Mollier` (moist air / psychrometrics)
- `SAM_IAPWS` (pure water/steam thermodynamics)
- `SAM_SolarCalculator` (solar irradiance and weather input models)
- `SAM_Mollier` — moist air and psychrometric calculations
- `SAM_IAPWS` — pure water and steam thermodynamics
- `SAM_SolarCalculator` — solar and weather-related calculations

Reference libraries include **PsychroLib** and **IAPWS-IF97**.

---

## 📁 Structure
## Repository structure

```
SAM_Validation/
Expand All @@ -42,39 +51,24 @@ SAM_Validation/
├── CreateSolution.md # How to create and configure the solution
```

Each toolkit directory contains:
Each module directory contains:
- `Test/`: Unit and integration tests.
- `validationfiles/`: Reference data used for validation.

---

## 📘 Getting Started
## Getting Started

➡️ See [RunInstructions.md](./RunInstructions.md) for first-time setup and test execution.
➡️ See [TestPlan.md](./TestPlan.md) for an overview of planned and implemented tests.
➡️ See [CreateSolution.md](./CreateSolution.md) for help creating a solution and linking references.
➡️ See [RunInstructions.md](./RunInstructions.md) — how to configure and execute tests
➡️ See [TestPlan.md](./TestPlan.md) — overview of test coverage and status
➡️ See [CreateSolution.md](./CreateSolution.md) — solution setup and project linking

---

## 🧪 Current Test Coverage

### ✅ `SAM_Mollier/Test/HumidityRatioTests.cs`
Validates:
- `HumidityRatio.HumidityRatio(...)` against PsychroLib 2.5.0
- Tolerance: ±0.0005 kg/kg

More tests to come:
- Enthalpy
- Dew point
- Wet bulb

---

## 🔧 Run the Tests Locally

Ensure you have:
- [.NET SDK 7.0](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)
- References to `SAM_Mollier` and optionally `SAM_Psychrometrics`
- Referenced SAM modules under test

```bash
dotnet test
Expand All @@ -86,37 +80,25 @@ dotnet test

- 🔗 [PsychroLib 2.5.0](https://github.com/psychrometrics/psychrolib)
- 🔗 [IAPWS-IF97 Steam Tables](https://www.iapws.org/relguide/IF97-Rev.pdf)
- 🔗 [SAM_Mollier](https://github.com/HoareLea/SAM_Mollier)

---

## 🛠 Roadmap

- [x] Validate humidity ratio (RH-based)
- [x] Validate enthalpy
- [ ] Validate dew point, wet bulb
- [ ] Add Region 1–5 tests for `SAM_IAPWS`
- [ ] Validate solar input with `SAM_SolarCalculator`
- [ ] Shared test utilities & loader helpers
- 🔗 [SAM_Mollier](https://github.com/SAM_BIM/SAM_Mollier)

---

## 👥 Maintainers

- **Michal Dengusiak** – Lead architect and domain expert

---
## Development notes

## Resources
* [Wiki](https://github.com/HoareLea/SAM_Validation/wiki)
- Target framework: **.NET / C#**
- Coding style follows standard SAM-BIM conventions.
- New or modified `.cs` files must include the SPDX header from `COPYRIGHT_HEADER.txt`

## Installing
## Licence

To install **SAM** from .exe just download and run [latest installer](https://github.com/HoareLea/SAM_Deploy/releases) otherwise rebuild using VS [SAM](https://github.com/HoareLea/SAM)
This repository is free software licensed under the
**GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later)**.

## Licence ##
Each contributor retains copyright to their respective contributions.
The project history (Git) records authorship and provenance of all changes.

SAM is free software licenced under GNU Lesser General Public Licence - [https://www.gnu.org/licenses/lgpl-3.0.html](https://www.gnu.org/licenses/lgpl-3.0.html)
Each contributor holds copyright over their respective contributions.
The project versioning (Git) records all such contribution source information.
See [LICENSE](https://github.com/HoareLea/SAM_Template/blob/master/LICENSE) and [COPYRIGHT_HEADER](https://github.com/HoareLea/SAM/blob/master/COPYRIGHT_HEADER.txt).
See:
- `LICENSE`
- `NOTICE`
- `COPYRIGHT_HEADER.txt`