<commit_before>package se.raddo.raddose3D;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * This class defines the absorption properties of the container
 * encasing the irradiated sample. In this class the container material
 * is defined as a list of its component elements.
 * The container introduces an additional attenuation factor to the
 * beam before it reaches the sample.
 */
public class ContainerElemental extends Container{

  /**
   * Conversion of beam energy from MeV to KeV
   */
  private static final double MEV_TO_KEV             = 1e3;

  /**
   * Conversion from microns to centimeters
   */
  private static final double MICRONS_TO_CENTIMETERS = 1e-4;

  /**
   * The material that the container is made from
   */
  private String              material;

  /**
   * The thickness of the container in microns
   */
  private final double        thickness;

  /**
   * The density of the material in grams per centimetre cubed
   */
  private final double        density;

  /**
   * The mass attenuation coefficient of the sample
   */
  private double              massAttenuationCoefficient;

  /**
   * The mass thickness of the sample. On the NIST website the mass
   * thickness is defined as the mass per unit area.
   */
  private double              massThickness;

  /**
   * The total fraction attenuation of the X-ray beam due to the container
   */
  private double              containerAttenuationFraction;

  /**
   * A list of the elements from which the container is composed
   */
  private final List<String>  elementNamesList;

  /**
   * A list of the corresponding element occurrences
   */
  private final List<Double>  elementNumsList;

  /**
   * Element database keeping the coefficients of all elements.
   */
  private final ElementDatabase      elementDB;

  /**
   * Constructor for the ContainerMixture class.
   *
   * @param conThickness
   *          Double type argument giving the thickness of the
   *          container in microns.
   * @param conDensity
   *          Double type argument giving the density of the
   *          container in grams per centimetre cubed.
   */
  public ContainerElemental(Double conThickness, Double conDensity,
      List<String> containerElementNames,
      List<Double> containerElementNums) {

    /**
     * Initialise the instance variables
     */
    this.thickness = 0;
    this.density = 0;
    this.elementNamesList = containerElementNames;
    this.elementNumsList = containerElementNums;
    this.elementDB = ElementDatabase.getInstance();

    //Loop through elements in the element list and return the full compound as a
    //String
    this.material = "";
    for (int i = 0; i < containerElementNames.size(); i++) {
      this.material += containerElementNames.get(i);
      int elementAtomNum = (int) Math.round(containerElementNums.get(i));
      if (elementAtomNum > 1) {
        this.material += String.valueOf(elementAtomNum);
      }
    }
  }

  /**
   * Calculate the fraction by which the beam is attenuated by the container
   *<commit_msg>Instance variables are initialised to the user input variables in constructor rather than being set to zero.<commit_after>package se.raddo.raddose3D;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * This class defines the absorption properties of the container
 * encasing the irradiated sample. In this class the container material
 * is defined as a list of its component elements.
 * The container introduces an additional attenuation factor to the
 * beam before it reaches the sample.
 */
public class ContainerElemental extends Container{

  /**
   * Conversion of beam energy from MeV to KeV
   */
  private static final double MEV_TO_KEV             = 1e3;

  /**
   * Conversion from microns to centimeters
   */
  private static final double MICRONS_TO_CENTIMETERS = 1e-4;

  /**
   * The material that the container is made from
   */
  private String              material;

  /**
   * The thickness of the container in microns
   */
  private final double        thickness;

  /**
   * The density of the material in grams per centimetre cubed
   */
  private final double        density;

  /**
   * The mass attenuation coefficient of the sample
   */
  private double              massAttenuationCoefficient;

  /**
   * The mass thickness of the sample. On the NIST website the mass
   * thickness is defined as the mass per unit area.
   */
  private double              massThickness;

  /**
   * The total fraction attenuation of the X-ray beam due to the container
   */
  private double              containerAttenuationFraction;

  /**
   * A list of the elements from which the container is composed
   */
  private final List<String>  elementNamesList;

  /**
   * A list of the corresponding element occurrences
   */
  private final List<Double>  elementNumsList;

  /**
   * Element database keeping the coefficients of all elements.
   */
  private final ElementDatabase      elementDB;

  /**
   * Constructor for the ContainerMixture class.
   *
   * @param conThickness
   *          Double type argument giving the thickness of the
   *          container in microns.
   * @param conDensity
   *          Double type argument giving the density of the
   *          container in grams per centimetre cubed.
   */
  public ContainerElemental(Double conThickness, Double conDensity,
      List<String> containerElementNames,
      List<Double> containerElementNums) {

    /**
     * Initialise the instance variables
     */
    this.thickness = conThickness;
    this.density = conDensity;
    this.elementNamesList = containerElementNames;
    this.elementNumsList = containerElementNums;
    this.elementDB = ElementDatabase.getInstance();

    //Loop through elements in the element list and return the full compound as a
    //String
    this.material = "";
    for (int i = 0; i < containerElementNames.size(); i++) {
      this.material += containerElementNames.get(i);
      int elementAtomNum = (int) Math.round(containerElementNums.get(i));
      if (elementAtomNum > 1) {
        this.material += String.valueOf(elementAtomNum);
      }
    }
  }

  /**
   * Calculate the fraction by which the beam is attenuated by the container
   *
{'fraction_non_alphanumeric': 0.07384753095628822, 'fraction_numerical': 0.002386990899597195, 'mean_word_length': 2.804767309875142, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1682986', 'n_tokens_mistral': 1851, 'n_tokens_neox': 1757, 'n_words': 654}