Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate safety distances using OBZ when simple safety is not available #1427

Closed
wants to merge 2 commits into from

Conversation

elliottbiondo
Copy link
Contributor

The MR "hooks up" the OBZ safety distance calculation capability by using it within SimpleUnitTracker to calculate safety distances when simple safety is not available.

@elliottbiondo
Copy link
Contributor Author

@sethrj this is ready for your review.

I believe everything in this MR and my previous MR are correct, but I am suspicious of the OBZ inner bbox that is being created upon construction. In the GDML file I added here, I have a cone of r=13 and z=50 centered at the origin. As you can see, the outer bbox is correct. However, I don't under why the inner bbox spans z = (-12.5, 0). No matter what is chosen for the inner bbox x and y widths, the inner bbox should always start at z=-25. Obviously the way we are calculating bboxs by truncating all space with planes does not always yield the analytic solution, but I don't see where the -12.5 could be coming from.

OBZ for the cone volume
Inner: Half widths: (4.596195, 4.596195, 12.500001), offset: (0.000000, 0.000000, -12.500000)
Outer: half widths: (13.000001, 13.000001, 25.000002), offset: (0.000000, 0.000000, 0.000000)
Overall tranform (0., 0., 0.)

Copy link

github-actions bot commented Sep 26, 2024

Test summary

 3 157 files   4 968 suites   3m 21s ⏱️
 1 500 tests  1 473 ✅ 26 💤 1 ❌
16 601 runs  16 538 ✅ 62 💤 1 ❌

For more details on these failures, see this check.

Results for commit 54e5cef.

♻️ This comment has been updated with latest results.

@elliottbiondo
Copy link
Contributor Author

CI failures from src/celeritas/optical/action/BoundaryAction.cu appear to be unrelated

@sethrj sethrj self-requested a review September 27, 2024 11:35
@sethrj sethrj added enhancement New feature or request orange Work on ORANGE geometry engine labels Sep 27, 2024
@@ -100,6 +101,7 @@ class SimpleUnitTracker

ParamsRef const& params_;
SimpleUnitRecord const& unit_record_;
detail::OrientedBoundingZone::StoragePointers obz_storage_;
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be created on the fly since we keep params_ around

= params_.volume_records[unit_record_.volumes[volid]].obz_id;
detail::OrientedBoundingZone obz(params_.obz_records[obz_id],
obz_storage_);
return obz.calc_safety_inside(pos);
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately it's not going to be this simple: we need the minimum over both "inside current volume" and "outside all directly enclosed volumes". I'm not sure if we have that metadata yet, in fact...

<physvol>
<volumeref ref="vol3"/>
<position ref="origin"/>
</physvol>
Copy link
Member

Choose a reason for hiding this comment

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

I think these three enclosed volumes are overlapping. It might be more natural for you to make a geometry with orange/orangeinp/UnitProto.test.cc using the InputBuilderTest harness.

@@ -967,6 +973,22 @@ TEST_F(FiveVolumesTest, TEST_IF_CELERITAS_DOUBLE(heuristic_init))
}
}

TEST_F(ConeTest, safety)
{
Copy link
Member

Choose a reason for hiding this comment

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

Oh crap, I forgot that the Geant input gets scaled into the native unit system (unlike the .org.json files which are precalculated). This test is with the CLHEP unit system which scales everything by a factor of 10. I think it would be better to build a geometry with the InputBuilder test... sorry 😞

@sethrj
Copy link
Member

sethrj commented Sep 28, 2024

There's also a build error due to StoragePointers: it should have CELER_FUNCTION explicit operator bool(), not just operator bool.

@elliottbiondo
Copy link
Contributor Author

Closing this MR. Discussing with @sethrj, this approach will not work in the short term. The OBZ inner bounding box does not exclude inner volumes (this is a good thing because if it did, it would be too small to be useful in many cases). A consequence of this is that when checking inner safety distances, we would have to check the outer safety distances of internal volumes. Volumes don't currently have metadata denoting what internal volumes are contained. While this could be remedied when converting from G4 (in which the concept of internal volumes is a baked into the geometry format), it is not clear how it could be done during construction in the general CSG case. As we implement more specialized features we may need to split things up so that ORANGE differentiates between HEP and nuclear (i.e., general CSG) geometries, which would be a considerable undertaking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request orange Work on ORANGE geometry engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants