Skip to content

geometric_object_volume#45

Merged
stevengj merged 5 commits intomasterfrom
object_vol
Nov 6, 2019
Merged

geometric_object_volume#45
stevengj merged 5 commits intomasterfrom
object_vol

Conversation

@stevengj
Copy link
Collaborator

Adds new geometric_object_volume function to compute the volume of a given object.

Speeds up box_overlap_with_object when the object is entirely contained within the box, by using the analytical volume formula instead of numerical integration in this case.

@oskooi
Copy link
Collaborator

oskooi commented Oct 30, 2019

python/tests/fragment_stats.py is failing:

Using MPI version 3.1, 2 processes
FF....FFFFFFFFF.F.......FFF.F........F....F.................
======================================================================
FAIL: test_1d (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 89, in test_1d
    self._test_1d([])
  File "./tests/fragment_stats.py", line 82, in _test_1d
    cond=300 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 300.0

======================================================================
FAIL: test_1d_with_overlap (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 104, in test_1d_with_overlap
    self.check_stats(fs, a_eps=300, a_mu=300, nonlin=600, susc=700, cond=600)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 600

======================================================================
FAIL: test_1d_with_partial_fragment (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 117, in test_1d_with_partial_fragment
    self.check_stats(fs, a_eps=260, a_mu=260, nonlin=480, susc=480, cond=480)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 480

======================================================================
FAIL: test_1d_with_pml (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 95, in test_1d_with_pml
    self._test_1d([], pml=[mp.PML(1)])
  File "./tests/fragment_stats.py", line 82, in _test_1d
    cond=300 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 300.0

======================================================================
FAIL: test_1d_with_symmetry (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 92, in test_1d_with_symmetry
    self._test_1d([mp.Mirror(mp.X)])
  File "./tests/fragment_stats.py", line 82, in _test_1d
    cond=300 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 150.0

======================================================================
FAIL: test_2d (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 166, in test_2d
    self._test_2d([])
  File "./tests/fragment_stats.py", line 159, in _test_2d
    cond=30000 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 30000.0

======================================================================
FAIL: test_2d_with_pml_all_sides (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 172, in test_2d_with_pml_all_sides
    self._test_2d([], pml=[mp.PML(1, mp.Y), mp.PML(2, mp.X, mp.Low), mp.PML(3, mp.X, mp.High)])
  File "./tests/fragment_stats.py", line 159, in _test_2d
    cond=30000 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 30000.0

======================================================================
FAIL: test_2d_with_symmetry (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 169, in test_2d_with_symmetry
    self._test_2d([mp.Mirror(mp.X), mp.Mirror(mp.Y)])
  File "./tests/fragment_stats.py", line 159, in _test_2d
    cond=30000 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 7500.0

======================================================================
FAIL: test_cyl (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 268, in test_cyl
    self.check_stats(fs, a_eps=90000, a_mu=90000, nonlin=30000, susc=30000, cond=30000)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 30000

----------------------------------------------------------------------
Ran 31 tests in 0.038s

FAILED (failures=9)

Elapsed run time = 0.0442 s
..
======================================================================
FAIL: test_1d (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 89, in test_1d
    self._test_1d([])
  File "./tests/fragment_stats.py", line 82, in _test_1d
    cond=300 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 300.0

======================================================================
FAIL: test_1d_with_overlap (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 104, in test_1d_with_overlap
    self.check_stats(fs, a_eps=300, a_mu=300, nonlin=600, susc=700, cond=600)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 600

======================================================================
FAIL: test_1d_with_partial_fragment (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 117, in test_1d_with_partial_fragment
    self.check_stats(fs, a_eps=260, a_mu=260, nonlin=480, susc=480, cond=480)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 480

======================================================================
FAIL: test_1d_with_pml (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 95, in test_1d_with_pml
    self._test_1d([], pml=[mp.PML(1)])
  File "./tests/fragment_stats.py", line 82, in _test_1d
    cond=300 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 300.0

======================================================================
FAIL: test_1d_with_symmetry (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 92, in test_1d_with_symmetry
    self._test_1d([mp.Mirror(mp.X)])
  File "./tests/fragment_stats.py", line 82, in _test_1d
    cond=300 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 150.0

======================================================================
FAIL: test_2d (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 166, in test_2d
    self._test_2d([])
  File "./tests/fragment_stats.py", line 159, in _test_2d
    cond=30000 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 30000.0

======================================================================
FAIL: test_2d_with_pml_all_sides (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 172, in test_2d_with_pml_all_sides
    self._test_2d([], pml=[mp.PML(1, mp.Y), mp.PML(2, mp.X, mp.Low), mp.PML(3, mp.X, mp.High)])
  File "./tests/fragment_stats.py", line 159, in _test_2d
    cond=30000 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 30000.0

======================================================================
FAIL: test_2d_with_symmetry (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 169, in test_2d_with_symmetry
    self._test_2d([mp.Mirror(mp.X), mp.Mirror(mp.Y)])
  File "./tests/fragment_stats.py", line 159, in _test_2d
    cond=30000 / sym_factor)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 7500.0

======================================================================
FAIL: test_cyl (__main__.TestFragmentStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/fragment_stats.py", line 268, in test_cyl
    self.check_stats(fs, a_eps=90000, a_mu=90000, nonlin=30000, susc=30000, cond=30000)
  File "./tests/fragment_stats.py", line 25, in check_stats
    self.assertEqual(fragment.num_nonlinear_pixels, nonlin)
AssertionError: 0 != 30000

----------------------------------------------------------------------
Ran 31 tests in 0.040s

FAILED (failures=9)
-------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code.. Per user-direction, the job has been aborted.
-------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

  Process name: [[20345,1],1]
  Exit code:    1
--------------------------------------------------------------------------
FAIL tests/fragment_stats.py (exit status: 1)

}
case GEOM BLOCK: {
vector3 size = o.subclass.block_data->size;
double vol = size.x * size.y * size.z * fabs(matrix3x3_determinant(geometry_lattice.basis) / matrix3x3_determinant(o.subclass.block_data->projection_matrix));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failing tests are because a size of 0 in any dimension here makes vol equal to 0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I'll work around this by simply not using the geometric_object_volume optimization in 1d and 2d.

@stevengj stevengj merged commit fead47c into master Nov 6, 2019
@stevengj stevengj deleted the object_vol branch November 6, 2019 02:20
bmwiedemann added a commit to bmwiedemann/openSUSE that referenced this pull request Aug 17, 2020
https://build.opensuse.org/request/show/827344
by user badshah400 + dimstar_suse
- Update Source URL, moved to https://github.com/NanoComp/libctl.
- update to 4.5.0:
  * New `make_slanted_prism` functions to make a prism with
    a given sidewall angle (gh#NanoComp/libctl#53).
  * Defined `LIBCTL_MAJOR_VERSION` etc. in `ctlgeom.h` header file
    when using stand-alone libctlgeom.
  * Bugfix in point-in-prism test (gh#NanoComp/libctl#49).
  * `geom_object_volume` function to get the volume of a 3d
    object (accelerates `box_overlap_with_object` for objects
    completely within a box) (gh#NanoComp/libctl#45).
  * `ctl_printf_callback` so that callers can capture stdout
    (gh#NanoComp/libctl#39).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants