-
Notifications
You must be signed in to change notification settings - Fork 6
/
general-test-suite.py
37 lines (32 loc) · 1.02 KB
/
general-test-suite.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import numpy as np
from group_project import *
cmax = 12000
c0 = 9500
j0 = 9.5e-6
R = 1e-5
dr = 1e-7
Nr = R/dr
[cs,complete,errorflag] = spherical-diffusion(j0,c0,R,dr)
def test_completed():
"""
Tests whether the simulation was completed with no fatal errors.
The test passes if the simulation reached the final time step and no error flags were triggered.
"""
assert complete == 1
assert errorflag == 0
def test_inrange():
"""
Tests whether the concentration profile is in the allowed range.
The allowed range is defined as being between 0 and cmax.
The test passes if the final concentration is in this range for all r and t.
"""
assert cs.any > 0
assert cs.any < cmax
def test_continuity():
"""
Tests whether or not the concentration profile has any discontinuities.
A discontinuity is defined here as a finite difference being greater than cmax.
The test passes if no such discontinuities are detected.
"""
dc = cs[:,0:Nr-1]-cs[:,1:Nr]
assert dc.any < cmax