|Message: Re: Using density to define geometry||Not Logged In (login)|
Click on the Forum title, e.g. on the "Forums by Category" page, to read a sequence of postings to the Forum and its threads all in one page. If you are only interested in one thread or the thread following a specific posting, click the thread or the posting, which takes you to a smaller page, which contains only the part you are interested in and may be easier to navigate.
Messages are "chained" if there are only replies at the first level, i.e. 1/1.html, 1/1/1.html etc. In case of "chained" messages the message number is replaced by the icon and there is no indentation.
Inline: Display the subject line only or also the text of the posting(s); for the choice "All" the "Outline" choices are switched off.
|1||0||1||no text / full text of posting|
|2||1||All||text for level 1 only / text for All postings|
Outline: Choose the depth of the posting thread, successive toggle controls provide increasing detail.
|1||2||1||2 levels / 1 level (original posting)|
|2||3||2||3 levels / 2 levels|
|3||3||All||3 levels / all levels (all postings)|
On Tue, 04 Aug 2015 01:21:21 GMT, Michael H. Kelsey wrote:
> > 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. >
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.
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. But it doesn't. In fact, my box doesn't even show up. I have a detector behind this box and this is actually where I found the error. Because I was having the detector fill the empty space behind it, but was getting negative values. And even with using the units I am still getting these same errors. Honestly I don't understand what I am doing wrong. With units it works out on paper, I don't see why it doesn't on Geant4.
|Inline Depth:||Outline Depth:||Add message:|