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

[BUG] - Reverse translation (CSG-2-CAD) fails due to numpy 2.2.x #304

Closed
akolsek opened this issue Feb 24, 2025 · 1 comment
Closed

[BUG] - Reverse translation (CSG-2-CAD) fails due to numpy 2.2.x #304

akolsek opened this issue Feb 24, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@akolsek
Copy link
Member

akolsek commented Feb 24, 2025

Describe the bug

Fresh install of GEOUNED draws in numpy 2.2.X, which, at least in the case of MCNP-2-CAD translation ends up with an error. Few tests have been done and numpy 2.1.3 is the last version that still works. Downgrade of numpy is required for GEOUNED to work.

To Reproduce

Steps to reproduce the behavior:

  1. Install GEOUNED in conda (windows env).
  2. Do a reverse translation of a geometry.
  3. See error

Expected behavior

GEOUNED crashes with the attached error message.

Error message

{
	"name": "ValueError",
	"message": "The truth value of an empty array is ambiguous. Use `array.size > 0` to check that an array is not empty.",
	"stack": "---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 5
      1 import geouned
      3 geo = geouned.CsgToCad()
----> 5 geo.export_cad(
      6     input_filename='extracted.i',
      7     csg_format='mcnp',
      8     bounding_box=[3000,-3000,-5500,8000,3000,-2000],
      9     cell_range_type='all',
     10     mat_range_type='all',
     11     output_filename='divertor',
     12 )

File c:\\ProgramData\\Anaconda3\\envs\\geo_env\\Lib\\site-packages\\geouned\\GEOReverse\\core.py:104, in CsgToCad.export_cad(self, input_filename, csg_format, output_filename, bounding_box, universe_start, level_max, cell_range_type, cell_range, mat_range_type, mat_range)
     91 CADselection = {
     92     \"Ustart\": universe_start,
     93     \"levelMax\": level_max,
   (...)
    100     \"mat_range\": mat_range,
    101 }
    103 # TODO don't return fails variable, just fail in the method and raise the error there
--> 104 CADCells, fails = buildCAD(UnivCell, geo, CADselection)
    106 if fails:
    107     print(\"failed in conversion\", fails)

File c:\\ProgramData\\Anaconda3\\envs\\geo_env\\Lib\\site-packages\\geouned\\GEOReverse\\Modules\\buildCAD.py:23, in buildCAD(UnivCell, data, config)
     20 else:
     21     factor = 1
---> 23 modelSurfaces = data.GetSurfaces(scale=factor)  # scale change cm in mcnp to mm in CAD Obj
     25 # read Cells and group into universes
     26 print(config)

File c:\\ProgramData\\Anaconda3\\envs\\geo_env\\Lib\\site-packages\\geouned\\GEOReverse\\Modules\\MCNPinput.py:164, in McnpInput.GetSurfaces(self, scale)
    161     number += 1
    163 # return surface as surface Objects type
--> 164 return Get_primitive_surfaces(surf_cards, scale)

File c:\\ProgramData\\Anaconda3\\envs\\geo_env\\Lib\\site-packages\\geouned\\GEOReverse\\Modules\\MCNPinput.py:658, in Get_primitive_surfaces(mcnp_surfaces, scale)
    656     Stype, quadric = sq2params(Qparams)
    657 else:
--> 658     Stype, quadric = gq2params(Qparams)
    660 if Stype == \"cylinder\":
    661     # p = FreeCAD.Vector(quadric[0:3])
    662     # v = FreeCAD.Vector(quadric[3:6])
    663     # R = quadric[6]
    664     p, v, R = quadric

File c:\\ProgramData\\Anaconda3\\envs\\geo_env\\Lib\\site-packages\\geouned\\GEOReverse\\Modules\\MCNPinput.py:1261, in gq2params(x)
   1258 iz = zero[0]
   1259 comp = 2 * XD[iz]
   1260 if (
-> 1261     abs(comp) > 1e-6
   1262 ):  # zero eigenvalue but corresponding component in XD vector is non zero => paraboloid Curve => the k/comp value is the translation in this component direction
   1263     TD[iz] = -k / comp
   1264     U = (k, (iz, comp))

ValueError: The truth value of an empty array is ambiguous. Use `array.size > 0` to check that an array is not empty."
}

Screenshots

If applicable, add screenshots to help explain your problem.

Please complete the following information):

  • OS: Windows
  • GEOUNED v1.5.1
  • Python version: 3.11.11
  • numpy version: 2.2.3

Additional context

Downgrading numpy to v2.1.3 solves the issue.

@akolsek akolsek added the bug Something isn't working label Feb 24, 2025
psauvan added a commit to psauvan/GEOUNED that referenced this issue Mar 4, 2025
This was referenced Mar 4, 2025
AlvaroCubi added a commit that referenced this issue Mar 5, 2025
* Merge dev into main (#289)

* adding version 1.3.0 to docs (#274)

* Update version_switcher.json

Adding the new version to the documentation.

* correction sphere additional plane

* Adding the mention of libmamba solver to installation instructions (#280)

* optimal bounbox to fix Torus bug

* optimal bounbox to fix Torus bug

* Torus envelope fix (partially) (#286)

* Update of the documentation layout (#285)

* update_of_docs

* test

* update 2

* update 3

* update 4

* test 5

* update 6

* update 7

* update 8

* test materials

* test again

* final

---------

Co-authored-by: Jonathan Shimwell <[email protected]>
Co-authored-by: Patrick Sauvan <[email protected]>
Co-authored-by: Aljaz Kolsek (F4E) <[email protected]>

* numpy version bug in geoReverse

solve bug #304

---------

Co-authored-by: AlvaroCubi <[email protected]>
Co-authored-by: Jonathan Shimwell <[email protected]>
Co-authored-by: Aljaz Kolsek (F4E) <[email protected]>
@psauvan
Copy link
Member

psauvan commented Mar 11, 2025

solved PR #308

@psauvan psauvan closed this as completed Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants