コード例 #1
0
    def setUp(self):
        sample_details = SampleDetails(height=4.0,
                                       radius=0.2985,
                                       center=[0, 0, 0],
                                       shape='cylinder')
        sample_details.set_material(chemical_formula='Si')
        self.geometry = {
            'Shape': 'Cylinder',
            'Height': sample_details.height(),
            'Radius': sample_details.radius(),
            'Center': sample_details.center()
        }

        material = sample_details.material_object
        material_json = {'ChemicalFormula': material.chemical_formula}
        if material.number_density:
            material_json["SampleNumberDensity"] = material.number_density
        if material.absorption_cross_section:
            material_json[
                "AttenuationXSection"] = material.absorption_cross_section
        if material.scattering_cross_section:
            material_json[
                "ScatteringXSection"] = material.scattering_cross_section
        self.material = material_json

        self.cal_file_path = "polaris_grouping_file.cal"
コード例 #2
0
    def setUp(self):
        sample_details = SampleDetails(height=4.0, radius=0.2985, center=[0, 0, 0], shape='cylinder')
        sample_details.set_material(chemical_formula='Si')
        self.geometry = {'Shape': 'Cylinder',
                         'Height': sample_details.height(),
                         'Radius': sample_details.radius(),
                         'Center': sample_details.center()}

        material = sample_details.material_object
        material_json = {'ChemicalFormula': material.chemical_formula}
        if material.number_density:
            material_json["SampleNumberDensity"] = material.number_density
        if material.absorption_cross_section:
            material_json["AttenuationXSection"] = material.absorption_cross_section
        if material.scattering_cross_section:
            material_json["ScatteringXSection"] = material.scattering_cross_section
        self.material = material_json

        self.dirpath = tempfile.mkdtemp()
        self.cal_file_path = os.path.join(self.dirpath, "tot_scat.cal")
        file = open(self.cal_file_path, 'w')
        file.write("%i\t%i\t%f\t%i\t%i\n" % (1, 1, 0.0, 1, 1))
        file.write("%i\t%i\t%f\t%i\t%i\n" % (2, 2, 0.0, 1, 1))
        file.write("%i\t%i\t%f\t%i\t%i\n" % (3, 3, 0.0, 1, 2))
        file.write("%i\t%i\t%f\t%i\t%i\n" % (4, 4, 0.0, 1, 2))
        file.close()