Problem 2036 - Bug in G4MaterialPropertiesTable::AddConstProperty
Summary: Bug in G4MaterialPropertiesTable::AddConstProperty
Status: RESOLVED DUPLICATE of problem 2030
Alias: None
Product: Geant4
Classification: Unclassified
Component: materials (show other problems)
Version: 10.4
Hardware: All All
: P4 normal
Assignee: Marc.Verderi
URL:
Depends on:
Blocks:
 
Reported: 2018-02-22 00:13 CET by Shawn Tornga
Modified: 2018-03-03 01:00 CET (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Shawn Tornga 2018-02-22 00:13:33 CET
In the G4MaterialPropertiesTable::AddConstProperty method of G4MaterialPropertiesTable (located in G4MaterialsPropertiesTable.icc), it is impossible to add a new constant property key because the first call is to GetConstPropertyIndex on the provided (NEW) key, which doesn't exist and throws and exception. 

I believe that it should do something like below: (unless of course it's not intended to add new keys ... ). This would make the mapping of constant parameter names non-constant. Another option would be to change the method name to SetConstProperty since really, as it stands, the method can set only existing constant property key values. 

The reason I think it should allow for additional constant property keys is because the user may want to register newly named properties for different materials.

inline void G4MaterialPropertiesTable::AddConstProperty(const char *key, 
  G4double PropertyValue)
{
  // Provides a way of adding a constant property to the Material Properties
  // Table given a key
  auto it = G4MaterialConstPropertyName.find(G4String(key));
  if (it == G4MeterialConstPropertyName.end()) {
    G4MaterialConstPropertyName.insert(G4String(key));
  }
  G4MCPindex index = GetConstPropertyIndex(G4String(key));
  MCP[index] = PropertyValue;
}
Comment 1 Daren Sawkey 2018-02-23 17:48:47 CET
Thanks for your report. This is fixed in the upcoming 10.4.patch1 release. Please let me know if you'd like the fix earlier.

Marc, this can be marked as duplicate of 2030.
Comment 2 asai 2018-03-03 01:00:06 CET

*** This problem has been marked as a duplicate of problem 2030 ***