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

Steven Walton writes:
> Yes, I am trying to vary a box to have constant mass. And I am switching
> materials. I want the box to just be changing in thickness and
> everything else to be constant.

That's a very sensible request, and the G4 units system should handle it.

> I am still at a loss here. Because if we look back to what I wrote in
> the OP I had
> 
>    G4double density = kevlarDensity; // 1.44 * g/cm3 from above
>    G4double mass = 1. * g;
>    G4double Box_y, Box_z = 1. * cm;
>    G4double thickness = mass/(density * Box_y * Box_z);
> 
> So all of these have their correct units. (kevlarDensity was defined in
> the DefineMaterials() function to be 1.44*g/cm3) So we are correctly
> multiplying and dividing units. Or if I am not, I do not see where.
> Because in thickness I essentially have
> 
>    G4double thickness = (1.*g)/((1.44*g/cm3) * (1.*cm) * (1.*cm));
> 
> Which should result in 0.694444 * cm.

I think there must be an error somewhere else in your code; perhaps you've
not assigned units properly to some other quantity in your computations.  I
wrote a very simple test program to run exactly your numbers above.  Here is
the output:

Testing G4 internal vs. dimensioned units...
 density set to 1.44*g/cm3: 8.98777e+18 (internal) 
 1.44 g/cm3 = 1.44 g/cm3  (best)
 length 1 cm  = 10 (internal)
 width  1 cm  = 10 (internal)
 mass   1 g  = 0.001 kg = 6.24151e+21 (internal)
 computed thickness 6.94444 mm  = 0.694444 cm

The values I've marked "internal" are what you get if you dump the G4double
without doing any unit division; notice that both density and mass are huge,
because we (actually, CLHEP) use MeV as our internal unit for energy, and
mass is derived from it (see CLHEP/include/Units/SystemOfUnits.h).

Here is the code for my test program.  You can see where I assign specific
units to each value when it is declared, and I don't use any units
explicitly when computing the thickness.  I divide out the units (or call
G4BestUnit()) when I want to print values that are understandable.

#include <globals.hh>
#include <G4SystemOfUnits.hh>
#include <G4UnitsTable.hh>

int main() {
  G4cout << "Testing G4 internal vs. dimensioned units..." << G4endl;

  G4double density = 1.44*g/cm3;

  G4cout << " density set to 1.44*g/cm3: " << density << " (internal) "
  << "\n " << density/(g/cm3) << " g/cm3 = "
  << G4BestUnit(density,"Volumic Mass") << " (best)" << G4endl;

  G4double length = 1*cm;
  G4double width = 1*cm;
  G4double mass = 1*g;
  
  G4cout << " length " << G4BestUnit(length,"Length")
  << " = " << length << " (internal)"
  << "\n width  " << G4BestUnit(width,"Length")
  << " = " << width << " (internal)"
  << "\n mass   " << G4BestUnit(mass,"Mass") << " = " << mass/kg
  << " kg" << " = " << mass << " (internal)" << G4endl;
  
  G4double thickness = mass/(density*length*width);
  
  G4cout << " computed thickness " << G4BestUnit(thickness,"Length")
  << " = " << thickness/cm << " cm" << G4endl;
}

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

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