# Gasfile issue during running

**URL:** <https://root-forum.cern.ch/t/gasfile-issue-during-running/44119>\
**Category:** Garfield++\
**Created:** [March 22, 2021, 3:24pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119 "2021-03-22T15:24:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 22, 2021, 3:24pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/1 "2021-03-22T15:24:25Z")

</div>

@hschindl i was working on it and producing different gas files. now u want to produce another gas file by using example gasfile in garfield. but it is giving an error and not running see. as i have put name and parameter in generate.cc. can you help what is issue?

 ![Screenshot from 2021-03-22 20-17-52](https://root-forum.cern.ch/uploads/default/original/3X/1/3/13fd0fc2d312710224d7a6d5731517e7e570373b.jpeg)

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 22, 2021, 3:47pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/2 "2021-03-22T15:47:41Z")

</div>

dear another thing i’m replacing the gas file in the example geant4garfieldinterface in the file detectorconstruction.cc but its not compiling what is issue here i want you to help me in this regard too. please waiting for your answwer.

 ![Screenshot from 2021-03-22 20-44-05](https://root-forum.cern.ch/uploads/default/original/3X/c/4/c4e82f3261b6ead28f381090e3aafe65186bef74.jpeg)

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [March 22, 2021, 3:48pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/3 "2021-03-22T15:48:28Z")

</div>

The parameters of the function `SetComposition` are (in this order)

- name of the first component in the mixture (`string`),
- fraction of the first component in the mixture (`double`),
- name of the second component (`string`),
- fraction of the second component (`double`),
- and so on (up to six components).  
So, in your case:

```auto
gas.SetComposition("C2H4F2", 70., "C4H10", 30.);

```

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [March 22, 2021, 3:59pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/4 "2021-03-22T15:59:14Z")

</div>

Hard to say without seeing your code, but it looks like `C2F4H2` is a `G4Element` object while it should be a `G4Material` (first error) and you are using an object (`Ar`) that doesn’t exist.

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 24, 2021, 3:49pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/5 "2021-03-24T15:49:29Z")

</div>

oook dear i’ll show you more so you can explain if there is something else.

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 25, 2021, 4:15pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/6 "2021-03-25T16:15:46Z")

</div>

here the detector construction.cc with in the geant4garfieldinterface example of garfield. and i have tried to change and then error comes in make command which i have asked you previous day. i have made changes but why is errors?

 ![Screenshot from 2021-03-25 21-11-17](https://root-forum.cern.ch/uploads/default/original/3X/3/5/35fba3d68db3b7ca3dae6ff0b140c51d668ff111.png)

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 25, 2021, 4:24pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/7 "2021-03-25T16:24:10Z")

</div>

in this above pic you can see i have put the changes with c2f4h2 100% and with its gas file but still issues in make command.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [March 25, 2021, 4:46pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/8 "2021-03-25T16:46:56Z")

</div>

C2F4H2 is not an element, so I guess the line

```auto
nistManager->findOrBuildElement("C2F4H2", isotopes);

```

won’t work. I think you have to build a C2F4H2 `G4Material` the same way you do it for CO2.

Another issue, as I mentioned in my previous reply, is in the line

```auto
ArCO2_93_7->AddElement(Ar, fractionmass = 0.93);

```

It causes an error because there is no object called `Ar` in your function. This line (and the one before/after) is probably a left over from the original code (which did use Ar/CO2).

By the way, it would be great if (in the future) you could post your code as text instead of a picture.

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 26, 2021, 5:38am UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/9 "2021-03-26T05:38:45Z")

</div>

ok dear i’ll check then let you know. thanks a lot.

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 29, 2021, 2:24pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/10 "2021-03-29T14:24:30Z")

</div>

ahmer@ahmer-Dell-Precision-M3800 ~ cd Desktop ahmer@ahmer-Dell-Precision-M3800 ~/Desktop cd garfeidl  
bash: cd: garfeidl: No such file or directory  
ahmer@ahmer-Dell-Precision-M3800 ~/Desktop cd garfield ahmer@ahmer-Dell-Precision-M3800 ~/Desktop/garfield cd Examples/GasFile  
ahmer@ahmer-Dell-Precision-M3800 ~/Desktop/garfield/Examples/GasFile ls ar\_80\_co2\_20\_0T.gas ar\_80\_co2\_20\_2T.gas CMakeLists.txt generate.C merge.C read.C ahmer@ahmer-Dell-Precision-M3800 ~/Desktop/garfield/Examples/GasFile mkdir build  
ahmer@ahmer-Dell-Precision-M3800 ~/Desktop/garfield/Examples/GasFile cd build ahmer@ahmer-Dell-Precision-M3800 ~/Desktop/garfield/Examples/GasFile/build source /home/ahmer/Desktop/Geant4/geant4.10.06.p01-install/bin/geant4.sh  
ahmer@ahmer-Dell-Precision-M3800 ~/Desktop/garfield/Examples/GasFile/build source /home/ahmer/Desktop/root/test\_build/bin/thisroot.sh ahmer@ahmer-Dell-Precision-M3800 ~/Desktop/garfield/Examples/GasFile/build source /home/ahmer/Desktop/garfield/build/setup.sh  
ahmer@ahmer-Dell-Precision-M3800 ~/Desktop/garfield/Examples/GasFile/build cmake .. -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc - works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ - works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /home/ahmer/Desktop/garfield/Examples/GasFile/build ahmer@ahmer-Dell-Precision-M3800 ~/Desktop/garfield/Examples/GasFile/build make -j8  
Scanning dependencies of target read  
Scanning dependencies of target generate  
[25%] Building CXX object CMakeFiles/generate.dir/generate.C.o  
[50%] Building CXX object CMakeFiles/read.dir/read.C.o  
[75%] Linking CXX executable generate  
[100%] Linking CXX executable read  
[100%] Built target generate  
[100%] Built target read  
ahmer@ahmer-Dell-Precision-M3800 ~/Desktop/garfield/Examples/GasFile/build ls ar\_80\_co2\_20\_0T.gas ar\_80\_co2\_20\_2T.gas CMakeCache.txt CMakeFiles cmake\_install.cmake generate Makefile read ahmer@ahmer-Dell-Precision-M3800 ~/Desktop/garfield/Examples/GasFile/build ./generate  
Heed:  
Database path: /home/ahmer/Desktop/garfield/Heed/heed++/database  
MediumMagboltz::GetGasName:  
Gas G4\_FREON-12 is not recognized.  
MediumMagboltz::SetComposition:  
Error setting the composition. No valid components.  
MediumMagboltz::GenerateGasTable: Found 0 excitations and 0 ionisations.  
MediumMagboltz::GenerateGasTable: E = 100 V/cm, B = 0 T, angle: 1.5708 rad

```
 ERROR IN GAS INPUT : NGAS= 0

```

N= 1 NGAS= 0 FRAC= 0.000  
N= 2 NGAS= 0 FRAC= 0.000  
N= 3 NGAS= 0 FRAC= 0.000  
N= 4 NGAS= 0 FRAC= 0.000  
N= 5 NGAS= 0 FRAC= 0.000  
N= 6 NGAS= 0 FRAC= 0.000  
MediumMagboltz::RunMagboltz: Results:  
Drift velocity along E: 0.00000000 cm/ns +/- 0.00%  
Drift velocity along Bt: 0.00000000 cm/ns +/- 0.00%  
Drift velocity along ExB: 0.00000000 cm/ns +/- 0.00%  
Lorentz angle: 0.000 degree  
Longitudinal diffusion: -nan cm1/2 +/- 0.00%  
Transverse diffusion: -nan cm1/2 +/- 0.00%  
Townsend coefficient: 0.0000 cm-1 +/- 0.00%  
Attachment coefficient: 0.0000 cm-1 +/- 0.00%  
MediumMagboltz::GenerateGasTable: E = 143.845 V/cm, B = 0 T, angle: 1.5708 rad

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 29, 2021, 2:26pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/11 "2021-03-29T14:26:56Z")

</div>

in this down pasted code i have tried to build the gas file for 100% freon.  
but as mentioned name in the list of materials is G4\_FREON-12 but the code is not picking it as you are seeing in the code the errors how to fix it?

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [March 29, 2021, 7:11pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/12 "2021-03-29T19:11:12Z")

</div>

Hi,  
`G4_FREON-12` is not a valid identifier for C2H4F2. You can use one of the following:

- `"C2H2F4"`, `"C2F4H2"`,
- `"FREON 134"`, `"FREON 134A"`, `"FREON-134"`, `"FREON-134-A"`,
- `"TETRAFLUOROETHANE"`

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 30, 2021, 3:39pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/13 "2021-03-30T15:39:59Z")

</div>

ok dear i’ll try with others. but G4\_FREON-12 was in the /material/nist/list material. i have checked then why is it not working?

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 30, 2021, 3:43pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/14 "2021-03-30T15:43:34Z")

</div>

and dear can you send me the material list so i can also check material and its proper font.? my email. [ahmer.khan713@gmail.com](mailto:ahmer.khan713@gmail.com)

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [March 30, 2021, 4:09pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/15 "2021-03-30T16:09:12Z")

</div>

> [@ahmer\_k](#):
>
> G4\_FREON-12 was in the /material/nist/list material

That means that Geant4 has a material with that name in its list of materials, but that is completely separate from Garfield++/Magboltz. To set the gas mixture to C2H4F2 in MediumMagboltz, you need to use one of the labels/names I mentioned in my previous message.

By the way, I suspect that `G4_FREON-12` might correspond to [Dichlorodifluoromethane - Wikipedia](https://en.wikipedia.org/wiki/Dichlorodifluoromethane) and not [1,1,1,2-Tetrafluoroethane - Wikipedia](https://en.wikipedia.org/wiki/1,1,1,2-Tetrafluoroethane).

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [March 30, 2021, 4:12pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/16 "2021-03-30T16:12:30Z")

</div>

Do you mean a list of gases that are available in Magboltz?  
See Appendix B of the [Garfield++ user guide](https://garfieldpp.web.cern.ch/garfieldpp/documentation/UserGuide.pdf).

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 30, 2021, 5:12pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/17 "2021-03-30T17:12:02Z")

</div>

OK dear thanks i’ll see that too.

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 30, 2021, 5:33pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/18 "2021-03-30T17:33:50Z")

</div>

![Screenshot from 2021-03-30 22-25-08](https://root-forum.cern.ch/uploads/default/original/3X/b/d/bd89f7f5c3adfff97e042171fe4c85dab27c393e.png)  
in the above picture now i’m basically introduce my tetrafluoroethane gas file in the geant4garfieldinterface example. this picture is basically the picture of the detectorconstruction.cc src file. and also i have copied the generated file of c2h2f4 in the geant4garfieldinterface folder no other file is it right? kindly if you can tell me how to do it?

---

<div class="post-metadata">

**Author:** ![ahmer\_k](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ahmer_k/32/24214_2.png) [@ahmer\_k](https://root-forum.cern.ch/u/ahmer_k)\
**Post date:** [March 30, 2021, 5:39pm UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/19 "2021-03-30T17:39:28Z")

</div>

and also as i have to place the density, ionizing potential, and n-components? how to find that?

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [March 31, 2021, 9:59am UTC](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119/20 "2021-03-31T09:59:12Z")

</div>

I’m not a Geant4 expert, but I think you could do something like this:

```auto
G4Element* H = nistManager->FindOrBuildelement("H", isotopes);
G4Element* C = nistManager->FindOrBuildelement("C", isotopes);
G4Element* F = nistManager->FindOrBuildelement("F", isotopes);
 
G4Material* C2H2F4 = new G4Material("C2H2F4", 
    density = ... * CLHEP::mg / CLHEP::cm3, ncomponents = 3, kStateGas);
 C2H2F4->AddElement(C, natoms = 2);
 C2H2F4->AddElement(H, natoms = 2);
 C2H2F4->AddElement(F, natoms = 4);

```

I don’t know the density off hand, so you’ll need to replace the three dots by the actual number.

Incidentally, I would recommend to tidy up the function `DefineMaterials`. You define materials (e. g. Ar/CO2 70:30, Ar/CO2 93:7) in this function which seem to be remnants of the original code and which I believe you don’t use.  
Also note that this function defines only the materials on the Geant4 side of your program, it doesn’t do anything related to Garfield.

Regarding the density: you can assume that it is an ideal gas, so the number density at 0° C and atmospheric pressure is _N_ = 2.6867774e19 cm-3.  
To get the mass density you need to multiply this number by the atomic weight _A_ of the molecule and the atomic mass unit.

I think I asked this question before, but are you sure you need to interface Geant4 and Garfield++ for your study and cannot simply use Garfield++ only?

[Next page](https://root-forum.cern.ch/t/gasfile-issue-during-running/44119.md?page=2)
