From 576c4db02c83eaf76fe80268fb3efd489e58c2c8 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 5 Nov 2024 22:18:35 -0600 Subject: [PATCH 1/2] Updates to GQ characterization, imports, and testing --- src/openmc_cad_adapter/gqs.py | 26 ++++++++++++++++------ src/openmc_cad_adapter/to_cubit_journal.py | 14 +----------- test/test_local.py | 6 +++++ 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/openmc_cad_adapter/gqs.py b/src/openmc_cad_adapter/gqs.py index a764bc2..7b0a510 100644 --- a/src/openmc_cad_adapter/gqs.py +++ b/src/openmc_cad_adapter/gqs.py @@ -117,20 +117,32 @@ def find_type( rAa, rAc, delta, S, D ): if gq_type == ONE_SHEET_HYPERBOLOID: if abs( K_) < equivalence_tol: K_ = 0 - return ELLIPTIC_CONE + gq_type = ELLIPTIC_CONE if gq_type == TWO_SHEET_HYPERBOLOID: if abs( K_) < equivalence_tol: K_ = 0 - return ELLIPTIC_CONE + gq_type = ELLIPTIC_CONE if gq_type == ELLIPSOID: if abs( A_) < equivalence_tol: A_ = 0 - return ELLIPTIC_CYLINDER + gq_type = ELLIPTIC_CYLINDER elif abs( B_) < equivalence_tol: B_ = 0 - return ELLIPTIC_CYLINDER + gq_type = ELLIPTIC_CYLINDER elif abs( C_) < equivalence_tol: C_ = 0 - return ELLIPTIC_CYLINDER - else: - return (gq_type, A_, B_, C_, K_, translation, rotation_matrix) \ No newline at end of file + gq_type = ELLIPTIC_CYLINDER + + return (gq_type, A_, B_, C_, K_, translation, rotation_matrix) + + +__all__ = ["characterize_general_quadratic", + "ELLIPSOID", + "ONE_SHEET_HYPERBOLOID", + "TWO_SHEET_HYPERBOLOID", + "ELLIPTIC_CONE", + "ELLIPTIC_PARABOLOID", + "HYPERBOLIC_PARABOLOID", + "ELLIPTIC_CYLINDER", + "HYPERBOLIC_CYLINDER", + "PARABOLIC_CYLINDER"] \ No newline at end of file diff --git a/src/openmc_cad_adapter/to_cubit_journal.py b/src/openmc_cad_adapter/to_cubit_journal.py index f8e93ec..eff69ad 100644 --- a/src/openmc_cad_adapter/to_cubit_journal.py +++ b/src/openmc_cad_adapter/to_cubit_journal.py @@ -6,7 +6,6 @@ import sys import warnings -from numpy.linalg import matrix_rank import numpy as np try: @@ -18,18 +17,7 @@ from openmc.surface import Halfspace, Quadric from openmc.lattice import Lattice, HexLattice -from .gqs import ( - characterize_general_quadratic, - ELLIPSOID, - ONE_SHEET_HYPERBOLOID, - TWO_SHEET_HYPERBOLOID, - ELLIPTIC_CONE, - ELLIPTIC_PARABOLOID, - HYPERBOLIC_PARABOLOID, - ELLIPTIC_CYLINDER, - HYPERBOLIC_CYLINDER, - PARABOLIC_CYLINDER -) +from .gqs import * from .cubit_util import emit_get_last_id, reset_cubit_ids, new_variable from .geom_util import rotate, move from .cubit_util import emit_get_last_id, reset_cubit_ids, new_variable diff --git a/test/test_local.py b/test/test_local.py index 3600e75..2d87c64 100644 --- a/test/test_local.py +++ b/test/test_local.py @@ -122,3 +122,9 @@ def test_general_cone(request, run_in_tmpdir): cone = openmc.Cone(x0=0.0, y0=0.0, z0=0.0, r2=6.0, dx=1, dy=1, dz=1) g = openmc.Geometry([openmc.Cell(region=-cone)]) to_cubit_journal(g, world=(500, 500, 500), filename='cone.jou') + +@reset_openmc_ids +def test_gq_ellipsoid(request): + ellipsoid = openmc.Quadric(1, 2, 3, k=1) + g = openmc.Geometry([openmc.Cell(region=-ellipsoid)]) + to_cubit_journal(g, world=(500, 500, 500), filename='ellipsoid.jou') From 7e6eb8014fc898bb4c7ae166d26b681c7b61cfba Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 5 Nov 2024 22:46:25 -0600 Subject: [PATCH 2/2] Updating GQ test and adding a gold file --- test/gold/ellipsoid.jou | 19 +++++++++++++++++++ test/test_local.py | 1 + 2 files changed, 20 insertions(+) create mode 100644 test/gold/ellipsoid.jou diff --git a/test/gold/ellipsoid.jou b/test/gold/ellipsoid.jou new file mode 100644 index 0000000..4745421 --- /dev/null +++ b/test/gold/ellipsoid.jou @@ -0,0 +1,19 @@ +set echo off +set info off +set warning off +graphics pause +set journal off +set default autosize off +#CELL 1 +sphere radius 1 +#{ id1 = Id("body") } +body { id1 } scale x 1.0 y 0.7071067811865476 z 0.5773502691896257 +body { None } name "Cell_1" +group "mat:void" add body { None } +graphics flush +set default autosize on +zoom reset +set echo on +set info on +set warning on +set journal on diff --git a/test/test_local.py b/test/test_local.py index 2d87c64..31479f7 100644 --- a/test/test_local.py +++ b/test/test_local.py @@ -128,3 +128,4 @@ def test_gq_ellipsoid(request): ellipsoid = openmc.Quadric(1, 2, 3, k=1) g = openmc.Geometry([openmc.Cell(region=-ellipsoid)]) to_cubit_journal(g, world=(500, 500, 500), filename='ellipsoid.jou') + diff_gold_file('ellipsoid.jou')