Message: Re: Materials Definition Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Materials Definition 

Forum: Geometry
Re: Question Materials Definition (Nick Laver)
Date: 01 Sep, 2009
From: John Allison <John Allison>

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.

 Add Message Add Message
to: "Re: Materials Definition"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]