Message: Using density to define geometry Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Using density to define geometry 

Forum: Geometry
Date: 03 Aug, 2015
From: Steven Walton <Steven Walton>

So I am noticing that when I cout values of variables with units that I get extraordinary large numbers.

For example if I am defining Kevlar


   void DetectorConstruction::DefineMaterials()
   {
   ...
   G4double kevlarDensity;
   G4Material* kevlar = new G4Material("kevlar", kevlarDensity = 1.44 * g/cm3, 4);
   kevlar -> AddElement(elH, 10); // el* grabbed from NIST manager
   kevlar -> AddElement(elC, 14);
   kevlar -> AddElement(elO, 2);
   kevlar -> AddElement(elN, 2);
   
   G4cout << kevlarDensity;
   ...
   }


I get 8.98777e+18 as the output.

Is there a proper way to do this? Really I would like to be able to shift the size of a material based upon the density. For example I am trying to do


   void DetectorConstruction::DetectorConstruction()
   {
   ...
   G4Material * abs_mat = nist -> FindOrBuildMaterial("kevlar");
   
   G4double density = kevlarDensity;
   G4double mass = 1. * g;
   G4double Box_y, Box_z = 1. * cm;
   G4double thickness = mass/(density * Box_y * Box_z);
   
   G4cout << "density: " << density << G4endl;
   G4cout << "thickness: " << thickness << G4endl;
   ...
   }


But from G4cout I am getting:
density = 1.22038e+214 (yes, a different number than above)
thickness = 7.38082e+115

But doing it by hand I don't get anywhere near these numbers. I take it that there is something to do with the units here. What is the proper way to do this?

In my header file I have:
   
   ...
   private:
   ...
   G4double kevlarDensity;
   ...
   };
   #endif

defined, and this allows me to use the variable

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Using density to define geometry   (Michael H. Kelsey - 03 Aug, 2015)
(_ None: Re: Using density to define geometry   (Steven Walton - 03 Aug, 2015)
(_ Idea: Re: Using density to define geometry   (Michael H. Kelsey - 03 Aug, 2015)
(_ Sad: Re: Using density to define geometry   (Steven Walton - 03 Aug, 2015)
(_ None: Re: Using density to define geometry   (Mike Kelsey - 03 Aug, 2015)
(_ Question: Re: Using density to define geometry   (Steven Walton - 04 Aug, 2015)
(_ None: Re: Using density to define geometry   (Mike Kelsey - 04 Aug, 2015)
(_ Note: Re: Using density to define geometry   (Steven Walton - 04 Aug, 2015)
(_ More: Re: Using density to define geometry   (Michael H. Kelsey - 04 Aug, 2015)
(_ Ok: Re: Using density to define geometry   (Steven Walton - 05 Aug, 2015)
(_ Ok: Re: Using density to define geometry   (Michael H. Kelsey - 05 Aug, 2015)
 Add Message Add Message
to: "Using density to define geometry"

 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 ]