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

None Re: Using density to define geometry 

Forum: Geometry
Re: None Using density to define geometry (Steven Walton)
Re: None Re: Using density to define geometry (Michael H. Kelsey)
Date: 03 Aug, 2015
From: Steven Walton <Steven Walton>

On Mon, 03 Aug 2015 22:17:08 GMT, Michael H. Kelsey wrote:
> On Mon, 03 Aug 2015 22:00:12 GMT, Steven Walton wrote:
>
> > 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.
>
> You need to include the unit conversion in the output. What you're
> seeing is the internal storage of dimensional values in Geant4. For
> density, the internal units would be something like MeV/mm^3. Change
> your output to be:
>
> G4cout << kevlarDensity / (g/cm3) << " g/cm3" << G4endl;
>
> You can also ask Geant4 to do this for you automatically in output:
>
> G4cout << G4BestUnit(kevlarDensity, "Density") << G4endl;
>
> where G4BestUnit is defined in G4UnitsTable.hh.
>
> -- Michael Kelsey
>
Then how do I properly define my box


   G4Box* testBox = new G4Box("testBox",
                              thickness,
                              worldSize,
                              worldSize);
When I output
 
     G4cout << kevlarDensity / (g/cm3) << " g/cm3" << G4endl;

I get 1.95527e+195 g/cm3, which is the same output I get if I just output "density" (not the kevlarDensity). I've been trying to remove the units in my equation and then add the remaining unit I need but this doesn't seem to be working.

I've tried
     G4double density = kevlarDensity * cm3/g; // I've tried * (1/(g/cm3)) too
     ... like before ...
     G4double thickness = (mass/g)/(density * (Box_y/cm) * (Box_z/cm));
     G4cout << thickness << G4endl;

And I still get 1.25915e+122 (surprisingly the 1/(g/cm3) gives 5.10752e+121
I specifically tried to leave no units in to see if I get the proper length.

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

1 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: "Re: 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 ]