Package gov.nist.microanalysis.EPQLibrary

Examples of gov.nist.microanalysis.EPQLibrary.Strategy


        Element element =
                createUserDefinedMassAbsorptionCoefficientModelElement();

        // Extrator
        ExtractorManager.register("model", ModelExtractorFactory.REGISTERED);
        Strategy strategy =
                ModelExtractorFactory.USER_DEFINED_MASS_ABSORPTION_COEFFICIENT
                        .extract(element);

        // Test
        MassAbsorptionCoefficient mac =
                (MassAbsorptionCoefficient) strategy
                        .getAlgorithm(MassAbsorptionCoefficient.class);
        assertTrue(mac instanceof MassAbsorptionCoefficient.UserSpecifiedCoefficient);
        assertEquals(200.0,
                mac.compute(gov.nist.microanalysis.EPQLibrary.Element.Cu,
                        ToSI.eV(8904.0)), 1e-4);
View Full Code Here


        // Create simulation
        String name = extractor.getName();
        SpectrumProperties props = extractor.getSpectrumProperties();
        Map<String, Detector> detectors = extractor.getDetectors();
        Strategy strategy = extractor.getStrategy();

        // Apply models' strategy
        report(0.0, "Setup models");
        strategy.addAlgorithm(PhiRhoZAlgorithm.class, getCorrectionAlgorithm());
        AlgorithmUser.applyGlobalOverride(strategy);

        // Setup and run detectors
        int i = 0;
        double length = detectors.size();
View Full Code Here

     *             if an error occurs while saving the log file
     */
    private void createLog(Properties props)
            throws IOException {
        // Model
        Strategy strategy = AlgorithmUser.getGlobalStrategy();
        for (String algClass : strategy.listAlgorithmClasses()) {
            props.setProperty("model." + algClass,
                    strategy.getAlgorithm(algClass).toString());
        }
    }
View Full Code Here

        // Calculate x-ray transitions (if needed)
        if (transitions.isEmpty())
            transitions.addAll(findAllXRayTransitions(comp, props));

        // Calculate maximum depth
        Strategy strategy = AlgorithmUser.getGlobalStrategy();
        ElectronRange electronRange =
                (ElectronRange) strategy.getAlgorithm(ElectronRange.class);
        if (electronRange == null)
            electronRange = ElectronRange.Pouchou1991;

        double rMax;
        for (XRayTransition xrt : transitions) {
View Full Code Here

        double density =
                ToSI.gPerCC(props
                        .getNumericProperty(SpectrumProperties.SpecimenDensity));

        // Create strategy
        Strategy strategy = AlgorithmUser.getGlobalStrategy();
        PhiRhoZAlgorithm corrAlg =
                (PhiRhoZAlgorithm) strategy
                        .getAlgorithm(PhiRhoZAlgorithm.class);
        if (corrAlg == null)
            throw new NullPointerException("No correction algorithm defined");

        // Calculate PZs
View Full Code Here

            DTSA2Model nistModel = map.get(model);

            if (nistModel == null)
                throw new IOException("Model (" + model + ") not found");

            Strategy st = new Strategy();
            st.addAlgorithm(nistModel.type, nistModel.algorithm);
            return st;
        }
View Full Code Here

            // Read base model
            Element baseElement = modelElement.getChild("model", Extractor.ns);
            ModelExtractor extractor =
                    (ModelExtractor) ExtractorManager.getExtractor(baseElement
                            .getName());
            Strategy baseStrategy = extractor.extract(baseElement);
            MassAbsorptionCoefficient baseMAC =
                    (MassAbsorptionCoefficient) baseStrategy
                            .getAlgorithm(MassAbsorptionCoefficient.class);

            // Read MAC values
            UserSpecifiedCoefficient mac =
                    new UserSpecifiedCoefficient(baseMAC);

            gov.nist.microanalysis.EPQLibrary.Element absorber;
            double energy, macValue;
            int z, src, dest;
            XRayTransition transition;
            for (Element subelement : modelElement.getChildren("mac")) {
                try {
                    absorber =
                            gov.nist.microanalysis.EPQLibrary.Element
                                    .byAtomicNumber(subelement.getAttribute(
                                            "absorber").getIntValue());
                } catch (DataConversionException e) {
                    throw new IOException(e);
                }

                if (subelement.getAttribute("energy") != null) {
                    try {
                        energy =
                                subelement.getAttribute("energy")
                                        .getDoubleValue();
                    } catch (DataConversionException e) {
                        throw new IOException(e);
                    }

                } else {
                    try {
                        z = subelement.getAttribute("z").getIntValue();
                        src = subelement.getAttribute("src").getIntValue() - 1;
                        dest =
                                subelement.getAttribute("dest").getIntValue() - 1;
                    } catch (DataConversionException e) {
                        throw new IOException(e);
                    }

                    transition =
                            new XRayTransition(
                                    gov.nist.microanalysis.EPQLibrary.Element
                                            .byAtomicNumber(z),
                                    src, dest);

                    try {
                        energy = transition.getEnergy_eV();
                    } catch (EPQException e) {
                        throw new IOException(e);
                    }
                }

                macValue = Double.parseDouble(subelement.getText());

                mac.put(absorber, ToSI.eV(energy), macValue);
            }

            Strategy st = new Strategy();
            st.addAlgorithm(MassAbsorptionCoefficient.class, mac);
            return st;
        }
View Full Code Here



    @Test
    public void testGetStrategy() {
        Strategy strategy = extractor.getStrategy();

        AlgorithmClass alg =
                strategy.getAlgorithm(RandomizedScatterFactory.class);
        assertEquals(NISTMottScatteringAngle.Factory, alg);

        alg = strategy.getAlgorithm(IonizationCrossSection.class);
        assertEquals(AbsoluteIonizationCrossSection.BoteSalvat2008, alg);

        alg = strategy.getAlgorithm(MeanIonizationPotential.class);
        assertEquals(MeanIonizationPotential.Sternheimer64, alg);

        alg = strategy.getAlgorithm(BetheElectronEnergyLoss.class);
        assertEquals(BetheElectronEnergyLoss.JoyLuo1989, alg);

        alg = strategy.getAlgorithm(MassAbsorptionCoefficient.class);
        assertEquals(MassAbsorptionCoefficient.Null, alg);
    }
View Full Code Here

     */
    protected Strategy extractModels(Element root) throws IOException,
            EPQException {
        Element modelsRoot = root.getChild("models");

        Strategy strategy = new Strategy();

        ModelExtractor extractor;
        for (Element modelElement : modelsRoot.getChildren()) {
            extractor =
                    (ModelExtractor) ExtractorManager.getExtractor(modelElement
                            .getName());
            strategy.addAll(extractor.extract(modelElement));
        }

        return strategy;
    }
View Full Code Here

TOP

Related Classes of gov.nist.microanalysis.EPQLibrary.Strategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.