Skip to content
Open
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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install GNU Fortran
run: |
sudo apt-get update
sudo apt-get install --yes gfortran
- name: Generate Fortran dimensions
run: |
python pyscripts/gen_dim.py \
-o src/vpsc_src/parameters.dim \
--nphmx 1 --ngrmx 100 --nmodmx 6 --ntwmmx 2 \
--nsysmx 48 --ntwsmx 24
- name: Build stand-alone EVPSC
run: make -j2 evpsc
- name: Check executable
run: test -x evpsc
- name: Run Python tests
run: make test-python
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,14 @@ parsers: objdir/sx_version_tester.o
docs:
make -j all -f make_docs.mk

test-python:
python -m unittest discover -s tests -v

## distributed version
evpsc_dist: $(objects_evpsc_common)
$(FC) $(FLAGS) -o evpsc $(objects_evpsc_common)

.PHONY: all clean zip tar evpsc_dist parsers docs evpsc
.PHONY: all clean zip tar evpsc_dist parsers docs evpsc test-python
all: evpsc parsers docs

$(objects_evpsc_common): | $(OBJDIR)
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ The input files follow the VPSC conventions (`vpsc7.in`, single-crystal
and texture files). For a description of the VPSC input format, see
Chapter 5 of Tome and Lebensohn (2023) [6].

## Run tests

The Python helper tests use only the Python standard library and do not
require a Fortran compiler:

```sh
make test-python
```

GitHub Actions also builds the stand-alone `evpsc` executable with GNU
Fortran and runs the Python tests on pushes and pull requests. The
repository does not currently include a stand-alone simulation input
case, so CI verifies compilation and test execution rather than running
a material simulation.

## Run the Abaqus example

A one-element Abaqus/Standard example is in `umat/src/evpsc_incr/`.
Expand Down
81 changes: 81 additions & 0 deletions tests/test_gen_dim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import re
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
GEN_DIM = ROOT / "pyscripts" / "gen_dim.py"


class GenerateDimensionFileTests(unittest.TestCase):
def run_gen_dim(self, *args):
with tempfile.TemporaryDirectory() as temp_dir:
output = Path(temp_dir) / "parameters.dim"
subprocess.run(
[sys.executable, str(GEN_DIM), "-o", str(output), *args],
cwd=ROOT,
check=True,
capture_output=True,
text=True,
)
return output.read_text()

def assert_parameter(self, contents, name, value):
match = re.search(
rf"^\s*parameter\({name}=(\d+)\)\s*$",
contents,
flags=re.IGNORECASE | re.MULTILINE,
)
self.assertIsNotNone(match, f"missing parameter {name}")
self.assertEqual(int(match.group(1)), value)

def test_default_dimensions(self):
contents = self.run_gen_dim()

for name, value in {
"nphmx": 1,
"ngrmx": 10000,
"nmodmx": 6,
"ntwmmx": 2,
"nsysmx": 48,
"ntwsmx": 24,
"nneimx": 1,
"ndifmx": 12,
"iregime": 2,
}.items():
with self.subTest(parameter=name):
self.assert_parameter(contents, name, value)

def test_custom_dimensions_and_regime(self):
contents = self.run_gen_dim(
"--nphmx", "3",
"--ngrmx", "2500",
"--nmodmx", "4",
"--ntwmmx", "1",
"--nsysmx", "18",
"--ntwsmx", "6",
"--nneimx", "2",
"--ndifmx", "8",
"--iregime", "1",
)

for name, value in {
"nphmx": 3,
"ngrmx": 2500,
"nmodmx": 4,
"ntwmmx": 1,
"nsysmx": 18,
"ntwsmx": 6,
"nneimx": 2,
"ndifmx": 8,
"iregime": 1,
}.items():
with self.subTest(parameter=name):
self.assert_parameter(contents, name, value)


if __name__ == "__main__":
unittest.main()
Loading