Message: how to make an array of the same absorber with different characteristics Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question how to make an array of the same absorber with different characteristics 

Forum: Geometry
Date: 19 Jul, 2010
From: Mehmet <Mehmet>

Hi,

I would like to have 100 absorbers made of air each with different characteristics. Below is part of the code for two absorbers that works:

density = 0.015*kg/m3; pressure = 0.01*atmosphere; temperature = 440.79*kelvin; G4Material* air1 = new G4Material("Air1", density, ncomponents=1, kStateGas, temperature, pressure);

air1->AddMaterial(Air, fractionmass=1.);

density = 0.176*kg/m3; pressure = 0.115*atmosphere; temperature = 216.54*kelvin; G4Material* air2 = new G4Material("Air2", density, ncomponents=1, kStateGas, temperature, pressure);

air2->AddMaterial(Air, fractionmass=1.);

However, to have 100 absorbers of air, it seems I have to write hundreds of lines similiar to the ones above, which doesnt sound right to me. An array of air[100] would solve my problem. I tried something like

G4Material* air[i] = new G4Material("Air", density, ncomponents=1, kStateGas, temperature, pressure);

air[i]->AddMaterial(Air, fractionmass=1.);

but apparently it does not like the array air[i] in G4Material*. Do you think it is possible to make such an array, or any other way to solve my problem other than defining air1, air2, ....air100?

Thank you in advance,

Mehmet

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

1 None: Re: how to make an array of the same absorber with different characteristics   (michel maire - 24 Jul, 2010)
 Add Message Add Message
to: "how to make an array of the same absorber with different characteristics"

 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 ]