File: test-comptonprofiles.php

package info (click to toggle)
xraylib 4.0.0%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 46,936 kB
  • sloc: ansic: 16,103; f90: 8,746; java: 6,766; python: 1,497; cpp: 1,305; pascal: 1,139; makefile: 809; ruby: 622; php: 594; perl: 573; cs: 193; sh: 125
file content (55 lines) | stat: -rw-r--r-- 2,151 bytes parent folder | download | duplicates (2)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<? 
include("xrltest.php");
include("xraylib.php");

class TestComptonProfiles extends XrlTest {
	function test_pz_0() {
		$profile = ComptonProfile(26, 0.0);
		assertAlmostEqual(7.060, $profile, 1E-6);
		$profile = ComptonProfile_Partial(26, N1_SHELL, 0.0);
		assertAlmostEqual(1.550, $profile, 1E-6);
		$profile1 = ComptonProfile_Partial(26, L2_SHELL, 0.0);
		$profile2 = ComptonProfile_Partial(26, L3_SHELL, 0.0);
		assertAlmostEqual($profile1, $profile2, 1E-6);
	}

	function test_pz_100() {
		$profile = ComptonProfile(26, 100.0);
		assertAlmostEqual(1.8E-05, $profile, 1E-8);
		$profile = ComptonProfile_Partial(26, N1_SHELL, 100.0);
		assertAlmostEqual(5.1E-09, $profile, 1E-12);
		$profile1 = ComptonProfile_Partial(26, L2_SHELL, 100.0);
		$profile2 = ComptonProfile_Partial(26, L3_SHELL, 100.0);
		assertAlmostEqual($profile1, $profile2, 1E-10);
		assertAlmostEqual($profile1, 1.100E-8, 1E-10);
	}

	function test_pz_50() {
		$profile = ComptonProfile(26, 50.0);
		assertAlmostEqual(0.0006843950273082384, $profile, 1E-8);
		$profile = ComptonProfile_Partial(26, N1_SHELL, 50.0);
		assertAlmostEqual(2.4322755767709126E-07, $profile, 1E-12);
		$profile1 = ComptonProfile_Partial(26, L2_SHELL, 50.0);
		$profile2 = ComptonProfile_Partial(26, L3_SHELL, 50.0);
		assertAlmostEqual($profile1, $profile2, 1E-10);
		assertAlmostEqual($profile1, 2.026953933016568e-06, 1E-10);
	}
	
	function test_bad_input() {
		assertException(ValueError, "ComptonProfile", 0, 0.0);
		$profile = ComptonProfile(102, 0.0);
		assertException(ValueError, "ComptonProfile", 103, 0.0);
		assertException(ValueError, "ComptonProfile", 26, -1.0);
		assertException(ValueError, "ComptonProfile_Partial", 0, K_SHELL, 0.0);
		$profile = ComptonProfile_Partial(102, K_SHELL, 0.0);
		assertException(ValueError, "ComptonProfile_Partial", 103, K_SHELL, 0.0);
		assertException(ValueError, "ComptonProfile_Partial", 26, K_SHELL, -1.0);
		assertException(ValueError, "ComptonProfile_Partial", 26, -1, 0.0);
		assertException(ValueError, "ComptonProfile_Partial", 26, N2_SHELL, 0.0);
	}
}

$suite = new XrlTestSuite();
$suite->append(new TestComptonProfiles());
$suite->run();
?>