| Message: Re: Materials Definition | Not Logged In (login) |
|
On Mon, 31 Aug 2009 19:12:43 GMT, Nick Laver wrote:
G4Material* Water = new G4Material("Water", density= 1*g/cm3);
should be
G4int natoms;
G4Material* Water = new G4Material("Water", density= 1*g/cm3, 2);
See G4Material.hh:
//
// Constructor to create a material from a combination of elements
// and/or materials subsequently added via AddElement and/or AddMaterial
//
G4Material(const G4String& name, //its name
G4double density, //density
G4int nComponents, //nbOfComponents
G4State state = kStateUndefined, //solid,gas
G4double temp = STP_Temperature, //temperature
G4double pressure = STP_Pressure); //pressure
which shows that 3 arguments are needed (and 3 more may be optionally provided). The use of variables like "G4double density" and "G4int natoms" is (arguably) to make it easier to read. E.g., you could have:
G4int natoms, nelements;
G4Material* Water = new G4Material("Water", density= 1*g/cm3, nelements = 2);
The variables are entirely superfluous. But...why not use the Geant4 material database?
G4NistManager* man = G4NistManager::Instance();
G4Material* AIR = man->FindOrBuildMaterial("G4_AIR");
G4cout << AIR << G4endl;
G4Material* WATER = man->FindOrBuildMaterial("G4_WATER");
G4cout << WATER << G4endl;
...
To see what's available: http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/apas09.html.
|
|
to: |