Contributing

Start with a small, reproducible change

You can contribute without implementing a new EOS. A clarified unit, a runnable example, a regression test, or an explanation of a contract that is currently only implied by the source are all useful contributions. For a first change, reproduce one existing example, identify one confusing or incorrect behavior, and keep the fix focused. Discuss a new model or a public interface change with maintainers before investing in its implementation.

This page covers how to contribute: which layer a change belongs to, how to build and test it, and how to write documentation that teaches. The developer handbook covers the codebase itself — the repository map, the Fortran contracts, the numerical algorithms, the language interfaces, and the detailed build and test procedures. Read that handbook for where things live and how the tooling is configured; read this page for what a good contribution looks like.

Find the right layer

Goal Start here
Learn how a calculation is set up example/basics/ and doc/page/usage/
Add a thermodynamic equation src/models/ and the new-model guides
Understand derivative checks src/consistency/ and the existing model tests
Fix equilibrium behavior Reduce the state first, then inspect src/equilibria/ and related tests
Improve user instructions doc/page/, which becomes the FORD user guide
Explain a public routine’s contract Documentation comments beside its declaration in src/

Read the actual interface and a current caller together. In particular, do not infer whether a binding is a function or a subroutine from its name: the hyperdual and Tapenade energy interfaces differ, and the Tapenade routines are subroutines with a strict argument order. Configuring an existing model is almost always preferable to introducing an unnecessary new type.

The architecture page maps each of these layers to the files that implement it.

Build and test before you change anything

Establish a working baseline first. An unchanged build and an unchanged example that runs tell you whether a later failure is yours.

From the repository root, a GNU-toolchain loop consistent with the CI configuration in .github/workflows/CI.yml is:

fpm build --profile release --flag "-g -ffree-line-length-0" --compiler gfortran --c-compiler gcc
fpm run --example basics --profile release --flag "-g -ffree-line-length-0" --compiler gfortran --c-compiler gcc
fpm test --profile release --flag "-g -ffree-line-length-0" --compiler gfortran --c-compiler gcc

Run these sequentially, never as competing builds of the same tree. The basics target is registered explicitly in fpm.toml; automatic example discovery is disabled, so a file dropped into example/extra/ is not a runnable target until it is registered. Compiler flags above are GNU-specific, not a portable interface requirement.

Useful first diagnoses: a missing module during the first build usually means an earlier dependency or compiler failure, so read the first error rather than the last. Undefined BLAS or LAPACK symbols point at library installation and linking, not at thermodynamic algebra. Report compiler versions, flags, and the first failing command when asking for help.

The workflow page documents the dependencies, the separate Python build, the documentation build, and the pitfalls that cost time. The testing page shows how the tests are structured and how to add a standalone regression program.

What a good test looks like

Do not only demonstrate that a flash converges. For a model, check energy units and extensivity, derivatives against numerical differences, each optional output requested on its own, and the thermodynamic identities before testing any equilibrium calculation. Use physically meaningful states away from singularities first, and explain the tolerance you assert: compare quantities that carry the same units, and say whether the threshold is absolute or relative.

A regression test should fail for the original defect. If it passes both before and after your change, it is not testing the change. The testing handbook gives the standalone-program pattern and the tolerance rules used by the existing suite.

Documentation workflow

The Fortran documentation is generated by FORD. ford.md selects src/ for API extraction, doc/page/ for guide pages, doc/media/ for assets, and doc/ford_site/ for generated output. Edit the source Markdown and the source comments, never the generated HTML. Preserve page names and anchors where possible; the existing analtical.md spelling, for instance, is part of the link structure of the guide.

With FORD and its rendering prerequisites installed (the documentation workflow installs Graphviz, Pandoc, and the Python packages), build from the repository root:

ford ford.md

Then open the generated page and read it. A zero exit status does not mean the page is correct: check cross-references, mathematics, code blocks, tables, navigation, and images, and read the generation warnings. An unresolved [[symbol]] link is not repaired by ordinary Markdown rendering. Do not build the documentation while another process is writing the same output tree.

The Python API has a separate Sphinx workflow driven by .github/workflows/docs.yml; it is not rebuilt by FORD alone.

Write for a learner

Use this sequence for a new guide or a substantial example:

  1. Purpose and prerequisite. State the physical question and what the reader should already know. Say when to choose a different model or workflow instead.
  2. Meaning before syntax. Define the thermodynamic potential, the reference state, the units, and which variables a derivative holds fixed. Distinguish a total from a molar quantity, and a residual from an absolute property.
  3. A small runnable example. Include the imports, the declarations, the parameter setup, and the property call. Label partial snippets as fragments; never present an abstract type or pseudocode as a complete program. Declare one variable per line, as shown in the style guide.
  4. Interpretation. Say what each output means and what the reader should check. A residual close to zero is a diagnostic, not proof that a model is accurate.
  5. The failure path. Explain the likely unit, domain, shape, initialization, and convergence errors, and where to look next.
  6. Evidence and the next step. Compile the examples where possible, state the assumptions, and link the actual implementations and tests. Never invent numerical results or references. Distinguish a published equation from an illustrative parameter set.

Keep API comments and guide prose complementary. The API reference gives the exact arguments, ranks, optionality, and units of a routine; the guide explains why a reader would call it and how to interpret the answer. Describe why a numerical safeguard exists, not merely that the code contains one.

When a page needs to point at the implementation, link to the source path and to the developer handbook rather than repeating the codebase tour. A page should answer one reader’s question well.

Example of the declaration style

New and modified declarations use one variable per line, so that each quantity can carry its own unit or physical meaning:

use yaeos, only: pr
implicit none

real(pr), intent(in) :: n(:) !! Component mole amounts [mol]
real(pr), intent(in) :: V    !! Total volume [L], not molar volume
real(pr), intent(in) :: T    !! Temperature [K]
real(pr), intent(out) :: P   !! Pressure [bar]
real(pr) :: tol              !! Absolute comparison tolerance [bar]

This is a declaration fragment inside a procedure, not a standalone program. Do not group these as real(pr) :: n(2), V, T, P or integer :: i, j. The style guide states the rule and its rationale.

Before requesting review

  • Summarize the behavior that changed and why the change belongs at this layer.
  • Include a reproducer and the commands you actually ran. Identify anything you could not test, and anything that was already failing before your change.
  • Confirm that the documentation examples match the current interfaces and units, and that they compile.
  • Check the diff for unrelated edits, generated files, and accidental changes to parameter data. Do not discard another contributor’s work.
  • For generated automatic-differentiation routines, record the primal source, the generator and its version, and any integration edits, so that the derivatives can be regenerated and re-checked.
  • Keep the commit focused. One logical change per branch or commit makes the difference between a reviewable patch and a merge conflict.

Project contribution policy

For contribution policy and issue-reporting guidance, read the repository’s CONTRIBUTING.md. For a guided tour of the implementation, continue with the developer handbook.