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

TypeError on _dll.openmc_nuclide_collapse_rate #2781

Closed
shimwell opened this issue Nov 19, 2023 · 2 comments
Closed

TypeError on _dll.openmc_nuclide_collapse_rate #2781

shimwell opened this issue Nov 19, 2023 · 2 comments
Labels

Comments

@shimwell
Copy link
Member

Just making use of openmc.lib.nuclide.collapse_rate which calls _dll.openmc_nuclide_collapse_rate and then errors with a ctypes.ArgumentError: argument 1: TypeError: wrong type error

It looks like the self_index is the wrong type and causes the code to crash.

Link to line in source code
Screenshot from 2023-11-19 01-29-27

Bug Description

Steps to Reproduce

import numpy as np
import openmc
import openmc.lib
from ctypes import c_int, c_double
import openmc.deplete

mat1 = openmc.Material()
mat1.add_element('Be', 1)
mat1.set_density('atom/b-cm', 1)
my_materials=openmc.Materials([mat1])

surf1 = openmc.Sphere(r=610, boundary_type='vacuum')
surf1_region = -surf1
surf1_cell = openmc.Cell(region=surf1_region)

my_geometry = openmc.Geometry([surf1_cell])

my_settings = openmc.Settings()
my_settings.batches = 10
my_settings.particles = 500

model = openmc.model.Model(my_geometry, my_materials, my_settings)
model.export_to_model_xml()

openmc.lib.init()
nuc=openmc.lib.Nuclide('Be9')

MT =  c_int(16)
temperature =  c_double(294)
col=nuc.collapse_rate(MT, temperature,[0.,10.e6,20e6],[100.,200.,3.])

Environment

ubuntu 22.04, openmc-dev, python3.10.12

@paulromano
Copy link
Contributor

@shimwell You were very close to having a working code -- the only change you need is:

nuc = openmc.lib.nuclides['Be9']

The lib.Nuclide class itself takes an integer index (if only it were type hinted, that would have been obvious 😉), where lib.nuclides is a mapping that gives a lib.Nuclide object given the name.

@paulromano
Copy link
Contributor

Closing as this is not a bug; let me know if you run into further issues @shimwell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants