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

Idea 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)
Re: None Re: Using density to define geometry (Steven Walton)
Date: 03 Aug, 2015
From: Michael H. Kelsey <Michael H. Kelsey>

On Mon, 03 Aug 2015 22:39:21 GMT, Steven Walton wrote:
> > 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.

> 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.

The division I showed in the G4cout statement is _only_ for purposes of human readability. All of the dimensional parameters you pass into G4 functions should have the units multiplied into them. In the case of your box, you should have something like

    new G4Box("myBox", 10*cm, 1*m, 1*m);

or whatever. If you assign those quantities to variables, include the units in the assignment:

    G4double thickness = 10*cm;
    G4double length = 1*m;
    G4double width = 1*m;

In your example, you want to scale the thickness according to density, so that you always have a fixed mass of material (I guess). The simplest way to do this is to pre-set the total mass you want, e.g.,

    G4double kevlarMass = 1.44 * g/cm3 * 0.1*m3;    // Showing the density and volume explicity

    G4double density = // your scaled density here, in units of g/cm3
    G4double thickness = kevlarMass/density/length/width;

So long as you assigned all of the values with units, as I've shown above, you will end up with thickness in units of length consistent with the length and width.

If you go to print stuff out, just do the division in the G4cout statements, not in assignments.

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

1 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 ]