Commit ae8e05fe authored by Eoin Clerkin's avatar Eoin Clerkin
Browse files

Added a new test to see the relative weights of the components sum to

100%. Implemented only for contents by weights.
parent 6a492d26
......@@ -34,6 +34,9 @@ FS="[\t ]*"; # Spaces and tags as field seperators in media.geo
for (i = 1; i<=NF; i++)datum[i]=$i; # Loading in a line from media.geo fle to make it easy to work with.
RELATIVE_SUM=0;
content_by="weight"; # The relative content is by number of each atom or by relative weight of each atom.
if($1!="//" && $1!="0" && $1!="1" && $1!="" ){ # Excluding lines that are not first line in definition of medium
print "############################################################################################################";
getline # Obtaining information from subsequent line for additional flags.
......@@ -42,6 +45,7 @@ for (i = 1; i<=NF; i++)datum[i]=$i; # Loading in a line from media.geo fle to ma
fld=$4
epsil=$5
declare sensor;
if(sensflag==0) # Is the material active?
{
sensor="PASSIVE";
......@@ -53,6 +57,11 @@ for (i = 1; i<=NF; i++)datum[i]=$i; # Loading in a line from media.geo fle to ma
print datum[1], sensor; # Material and Active status.
if(datum[2]<0){
content_by="number" # Relative number
print "Containts by numer";
};
datum[2] = (datum[2]>0)? datum[2] : -1*datum[2]; # Making the NCOMP parameter always positive.
# NCOMP sign controlls the constitutes ratio definitions and is not needed for these tests.
......@@ -61,19 +70,41 @@ for (i = 1; i<=NF; i++)datum[i]=$i; # Loading in a line from media.geo fle to ma
printf "Atomic Number: %s\tAtomic Mass: %s\n", datum[2+i+datum[2]], datum[2+i]; # See https://fairroot.gsi.de/?q=node/34 for info regarding format ordering.
printf "AN[%d]=> %s : Mass = %s\n", datum[2+i+datum[2]], ELEMENT_NAME[strtonum(datum[2+i+datum[2]])], ELEMENT_MASS[strtonum(datum[2+i+datum[2]])];
# datum[2] is the number of components
# datum[2 + i] is subsequent component's atomic number
# datum[2 + i + datum[2]] is subsequenct component's atomic weight
# datum[2 + 2*datum[2] + 1] is the overall density of the material
# datum[3 + 2*datum[2] + i] is the subsequent relative amount of each compoment.
ERROR = abs( (datum[2+i] - ELEMENT_MASS[strtonum(datum[2+i+datum[2]])] )/datum[2+i])
# printf "1 MASS ENTERED %s ", datum[2+i];
# printf "2 ELEMENT MASS %s ", ELEMENT_MASS[strtonum(datum[2+i+datum[2]])];
# printf "3 SUBTRACTED MASS %s ", datum[2+i] - ELEMENT_MASS[strtonum(datum[2+i+datum[2]])];
printf "1 MASS ENTERED %s \n", datum[2+i];
printf "2 ELEMENT MASS %s \n", ELEMENT_MASS[strtonum(datum[2+i+datum[2]])];
if(datum[2]>1 && content_by~"weight"){
printf "RELATIVE AMOUNT: %0.2f%% \n", 100*datum[3 + 2*datum[2] + i];
RELATIVE_SUM+=datum[3 + 2*datum[2] + i];
};
printf "ERROR IS %f \t", ERROR;
if (ERROR > ACCEPTABLE_ERROR) {
FAIL=1;
printf "CHECK FAILED\n"
printf "CHECK FAILED\n\n"
} else {
printf "CHECK PASSED\n"
printf "CHECK PASSED\n\n"
};
};
# Check if the amount of material adds up to 100%
if(datum[2]>1 && content_by~"weight"){
printf "TOTAL AMOUNT COUNT RELATIVE SUMS: %0.2f%% \t\t\t", 100*RELATIVE_SUM;
if (RELATIVE_SUM==1){
printf "CHECK PASSED! %s \n\n", RELATIVE_SUM;
}else{
printf "CHECK FAILED! %s \n\n", RELATIVE_SUM;
};
};
print " " # Spacing
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment