Skip to content

Commit

Permalink
Merge pull request #294 from VirtualPlanetaryLaboratory/DocsUpdate
Browse files Browse the repository at this point in the history
Updated docs for testing and adding primary variables (Thanks David a…
  • Loading branch information
RoryBarnes committed Jun 21, 2024
2 parents 4b9957b + c0b2efb commit 7a87a63
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
26 changes: 26 additions & 0 deletions docs/primaryvariable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ block of code that initializes the other pieces of the UPDATE struct.
malloc(update[iBody].iNumPrimaryVariable * sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] =
malloc(update[iBody].iNumPrimaryVariable * sizeof(int *));
for (iSubStep=0; iSubStep < 4; iSubStep++) {
control->Evolve.daDerivProc[iSubStep][iBody][iVar] =
malloc(update[iBody].iNumEqns[iVar] * sizeof(double));
}
}
// Now allocate memory for the number of processes that affect this variable
Expand All @@ -192,6 +196,28 @@ variable.
assign a new value to this variable, you will overwrite the primary variable's
derivative (which would be bad!).
We then need to add some lines to ```module.c```. In InitializeModule, add
.. code-block:: bash
module->fnFinalizeUpdatePhysics =
malloc(iNumBodies * sizeof(fnFinalizeUpdateCarbManModule));
and in FinalizeModule, add
.. code-block:: bash
module->fnFinalizeUpdatePhysics[iBody] =
malloc(iNumModules * sizeof(fnFinalizeUpdateCarbManModule));
and
.. code-block:: bash
module->fnFinalizeUpdatePhysics[iBody][iModule] = &FinalizeUpdateNULL;
Please add them next to the other similar statements
Next we need to add code to the module file, physics.c in this example, for
which this primary variable will be added. First add a new function that
continues the initialization process:
Expand Down
12 changes: 10 additions & 2 deletions docs/tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@ further enabling confidence in the code's accuracy.
Test scripts live in the :code:`tests/` directory and are executed automatically
on every pull request with GitHub Actions. To perform the tests, we use :code:`pytest`, which will
find all Python files with the word :code:`test` somewhere in their name (side note:
if it's not meant to be a test, don't put :code:`test` in the file name!).
if it's not meant to be a test, don't put :code:`test` in the file name!). Under the :code:`tests`
directory are subdirectories whose names consists of VPLanet modules, e.g. BINARY and AtmescEqtideStellar.
These subdirectories contain the tests available for the module combinations of the subdirectory name.


The VPLanet team has made it easy to add or revise tests. Inside the :code:`tests/` directory
is a file called :code:`maketest.py`, which will generate a unit test from a set of valid infiles.
So a typical procedure to create a new test is to:

- Create a simulation that executes previously untested functionality
- Verify the results are accurate! (Obvious, we know, but please don't forget!)
- Copy the .in files t
- Create a subdirectory with a unique name for your test.
- Copy the .in files for your test into your new subdirectory
- cd to the :code:`tests` directory and run ```python maketest.py <modules/subdir>```, which the
argument is the relative to path to your new test
- Commit your .in files and the new :code:`test_<subdir>.py" file to the repository
- Issue a PR!
These unit tests not only ensure new modification don't break parts of the code
that already work. In addition, they are used to compute the fraction of the code
Expand Down

0 comments on commit 7a87a63

Please sign in to comment.