示例#1
0
    def get_scatterers(scattering_type: Union[str, List[str], float],
                       materials_properties: Dict[str, Any],
                       amset_data: AmsetData
                       ) -> List[Union[AbstractElasticScattering,
                                       AbstractInelasticScattering]]:
        # dynamically determine the available scattering mechanism subclasses
        scattering_mechanisms = {
            m.name: m for m in
            AbstractElasticScattering.__subclasses__() +
            AbstractInelasticScattering.__subclasses__()}

        if scattering_type == "auto":
            logger.info("Examining material properties to determine possible "
                        "scattering mechanisms")

            scattering_type = [
                name for name, mechanism in scattering_mechanisms.items()
                if all([materials_properties.get(x, False) for x in
                        mechanism.required_properties])]

            if not scattering_type:
                raise ValueError("No scattering mechanisms possible with "
                                 "material properties")

        else:
            for name in scattering_type:
                missing_properties = [
                    p for p in scattering_mechanisms[name].required_properties
                    if not materials_properties.get(p, False)]

                if missing_properties:
                    raise ValueError(
                        "{} scattering mechanism specified but the following "
                        "material properties are missing: {}".format(
                            name, ", ".join(missing_properties)))

        logger.info("The following scattering mechanisms will be "
                    "calculated: {}".format(", ".join(scattering_type)))

        return [scattering_mechanisms[name](materials_properties, amset_data)
                for name in scattering_type]
示例#2
0
    get_cross_section_values,
    get_projected_intersections,
)
from amset.log import log_list, log_time_taken
from amset.scattering.basic import AbstractBasicScattering
from amset.scattering.elastic import AbstractElasticScattering
from amset.scattering.inelastic import AbstractInelasticScattering
from amset.util import get_progress_bar

__author__ = "Alex Ganose"
__maintainer__ = "Alex Ganose"
__email__ = "*****@*****.**"

logger = logging.getLogger(__name__)

_all_scatterers: Union = (AbstractElasticScattering.__subclasses__() +
                          AbstractInelasticScattering.__subclasses__() +
                          AbstractBasicScattering.__subclasses__())
_scattering_mechanisms = {m.name: m for m in _all_scatterers}

ni = {
    "high": {
        "triangle": quadpy.t2.schemes["xiao_gimbutas_50"](),
        "quad": quadpy.c2.schemes["sommariva_50"](),
    },
    "medium": {
        "triangle": quadpy.t2.schemes["xiao_gimbutas_06"](),
        "quad": quadpy.c2.schemes["sommariva_06"](),
    },
    "low": {
        "triangle": quadpy.t2.schemes["centroid"](),