def test_sum_modifier():
    cp = ConfigParser(io.StringIO())
    pfr = Potential_Form_Registry(cp, register_standard=True)
    pfb = Potential_Form_Builder(pfr, Modifier_Registry())

    expression = "sum(as.constant 1.0 >=1.0 as.constant 2.0, >1.5 as.constant 3.0)"

    potdef = cp._parse_multi_range("A", expression).potential_form_instance
    potential_func = pfb.create_potential_function(potdef)

    assert pytest.approx(1.0) == potential_func(0.1)
    assert pytest.approx(1.0) == potential_func(0.5)
    assert pytest.approx(2.0) == potential_func(1.1)
    assert pytest.approx(5.0) == potential_func(1.6)

    # Try another expression
    expression = ">=0 as.constant 2.0 >=1.0 sum(as.constant 1.0 >= 2.0 as.constant 0.5, >=1.5 as.constant 10.0) >= 3.0 as.zero"

    potdef = cp._parse_multi_range("A", expression).potential_form_instance
    potential_func = pfb.create_potential_function(potdef)

    assert pytest.approx(2.0) == potential_func(0)
    assert pytest.approx(1.0) == potential_func(1)
    assert pytest.approx(11.0) == potential_func(1.6)
    assert pytest.approx(10.5) == potential_func(2.1)
    assert pytest.approx(0.0) == potential_func(3.1)
def test_sum_modifier():
    """Test instantiation of potential forms that use the sum() modifier and multiple ranges"""
    k = u"A"
    v = u"sum( as.constant 1.0 >=1.0 as.constant 2.0, >1.5 as.constant 3.0)"

    parser = ConfigParser(io.StringIO())

    potential_forms = [
        PotentialFormInstanceTuple(
            potential_form=u'as.constant',
            parameters=[1.0],
            start=MultiRangeDefinitionTuple(range_type=u">", start=0.0),
            next=PotentialFormInstanceTuple(potential_form=u'as.constant',
                                            parameters=[2.0],
                                            start=MultiRangeDefinitionTuple(
                                                range_type=u">=", start=1.0),
                                            next=None)),
        PotentialFormInstanceTuple(potential_form=u'as.constant',
                                   parameters=[3.0],
                                   start=MultiRangeDefinitionTuple(
                                       range_type=u">", start=1.5),
                                   next=None)
    ]

    expect = PotentialModifierTuple(modifier=u"sum",
                                    potential_forms=potential_forms,
                                    start=MultiRangeDefinitionTuple(
                                        range_type=u">", start=0.0),
                                    next=None)

    expect = PairPotentialTuple(species=k, potential_form_instance=expect)
    actual = parser._parse_multi_range(k, v)
    assert DeepDiff(expect, actual) == {}
def test_modifier_parse_exceptions():
    """Check that a ConfigException is raised when parse errors are encountered"""

    parser = ConfigParser(io.StringIO())
    with pytest.raises(ConfigParserException):
        parser._parse_multi_range(u"A",
                                  u"potential1 1.0 2.0 3.0 potential2 2.0")
def test_with_default_potentials():
  """Tests for potential forms defined by atsim.potentials"""

  cfg_string = u"""[Potential-Form]
buck_morse(r, A, rho, C, gamma, r_star, D) : as.buck(r,A,rho,C) + as.morse(r, gamma, r_star, D)
"""
  expect = atsim.potentials.plus(atsim.potentials.potentialforms.buck(1000.0, 0.1, 32.0),
    atsim.potentials.potentialforms.morse(0.2, 1.3, 25.0))(1.4)

  cfg = ConfigParser(io.StringIO(cfg_string))
  pfr = Potential_Form_Registry(cfg, True)
  buck_morse = pfr["buck_morse"](1000.0, 0.1, 32.0, 0.2, 1.3, 25.0)
  
  actual = buck_morse(1.4)
  assert pytest.approx(expect) == actual

  # Effectively the same test but mixing cexprtk definitions with the canned definition.
  cfg_string = u"""[Potential-Form]
buck(r, A, rho, C) : A*exp(-r/rho) - C/r^6
buck_morse(r, A, rho, C, gamma, r_star, D) : buck(r,A,rho,C) + as.morse(r, gamma, r_star, D)
"""

  cfg = ConfigParser(io.StringIO(cfg_string))
  pfr = Potential_Form_Registry(cfg, True)
  buck_morse = pfr["buck_morse"](1000.0, 0.1, 32.0, 0.2, 1.3, 25.0)
  
  actual = buck_morse(1.4)
  assert pytest.approx(expect) == actual
def test_parsed_sections():
    expect = [
        'tabulation', 'potential_form', 'eam_embed', 'eam_density', 'pair'
    ]
    expect.sort()

    with _get_dlpoly_resource_dir().join("CRG_Ce.aspot").open() as infile:
        cp = ConfigParser(infile)
        actual = cp.parsed_sections
        actual.sort()
    assert expect == actual

    expect = ['tabulation', 'potential_form', 'pair']
    expect.sort()

    with _get_lammps_resource_dir().join("zbl_spline.aspot").open() as infile:
        cp = ConfigParser(infile)
        actual = cp.parsed_sections
        actual.sort()
    assert expect == actual

    expect = [
        'tabulation', 'potential_form', 'eam_embed', 'eam_density_fs', 'pair'
    ]
    expect.sort()

    with _get_lammps_resource_dir().join(
            "AlFe_setfl_fs.aspot").open() as infile:
        cp = ConfigParser(infile)
        actual = cp.parsed_sections
        actual.sort()
    assert expect == actual
def test_sum_modifier_fs_start():
    k = u"Al->Al"
    v = u">=0 sum(dens4 0.00019850823042883 2.5 >2.5 as.zero)"

    parser = ConfigParser(io.StringIO())
    actual = parser._parse_multi_range(k, v)
    assert DeepDiff(MultiRangeDefinitionTuple(u">=", 0),
                    actual.potential_form_instance.start) == {}
def test_parse_potential_form_signature():
    pfstr = "buck_morse(r_ij, A,rho,C,D,gamma,r0)"

    cfg = ConfigParser(io.StringIO())
    expect = PotentialFormSignatureTuple(
        u"buck_morse", [u"r_ij", u"A", u"rho", u"C", u"D", u"gamma", u"r0"],
        False)
    actual = cfg._parse_potential_form_signature(pfstr)
    assert expect == actual
def test_duplicate_entries():
    assert issubclass(ConfigParserDuplicateEntryException,
                      ConfigParserException)
    assert issubclass(ConfigParserDuplicateEntryException,
                      ConfigurationException)

    aspot = u"""

[Pair]
U-U : as.buck 1000.0 0.1 32.0
U-U : as.buck 1000.0 0.2 32.0"""

    with pytest.raises(ConfigParserDuplicateEntryException):
        cp = ConfigParser(io.StringIO(aspot))

    aspot = u"""

[Pair]
O-U : as.buck 1000.0 0.1 32.0
U-O : as.buck 1000.0 0.2 32.0"""

    with pytest.raises(ConfigParserDuplicateEntryException):
        cp = ConfigParser(io.StringIO(aspot))

    aspot = u"""

[Pair]
O-U : as.buck 1000.0 0.1 32.0
U-U : as.buck 2000.0 0.2 16.0"""

    with pytest.raises(ConfigParserDuplicateEntryException):
        cp = ConfigParser(io.StringIO(aspot),
                          additional=[
                              ConfigParserOverrideTuple(
                                  u"Pair", u"O-U", u"as.buck 1000.0 0.1 32.0")
                          ])

    aspot = u"""

[Pair]
O-U : as.buck 1000.0 0.1 32.0
U-U : as.buck 2000.0 0.2 16.0"""

    with pytest.raises(ConfigParserDuplicateEntryException):
        cp = ConfigParser(io.StringIO(aspot),
                          additional=[
                              ConfigParserOverrideTuple(
                                  u"Pair", u"U-O", u"as.buck 1000.0 0.1 32.0")
                          ])
def test_list_items():
    expect = [
        ("Tabulation:target", "setfl"), ("Tabulation:nr", "1000"),
        ("Tabulation:dr", "0.01"), ("Tabulation:nrho", "1000"),
        ("Tabulation:drho", "0.01"),
        ("Potential-Form:buck_morse(r,A,rho,C,D,gamma,r0)",
         "as.buck(r,A,rho,C) + as.morse(r, gamma, r0, D)"),
        ("Potential-Form:density(r,n)", "(n/r^8) * 0.5 * (1+erf(20*(r-1.5)))"),
        ("EAM-Embed:Th", "as.sqrt -1.185"), ("EAM-Embed:U", "as.sqrt -1.806"),
        ("EAM-Embed:O", "as.sqrt -0.690"),
        ("EAM-Density:Th", "density 1742.622"),
        ("EAM-Density:U", "density 3450.995"),
        ("EAM-Density:O", "density 106.856"),
        ("Pair:O-O", "as.buck    830.283 0.352856 3.884372"),
        ("Pair:Th-Th", "as.buck 18600 0.2884 0.0"),
        ("Pair:U-U", "as.buck 18600 0.2747 0.0"),
        ("Pair:Th-O",
         "buck_morse 315.544 0.395903 0.0 0.62614 1.85960 2.49788"),
        ("Pair:U-O", "buck_morse 448.779 0.387758 0.0 0.66080 2.05815 2.38051")
    ]
    expect.sort()

    with _get_lammps_resource_dir().join("CRG_U_Th.aspot").open() as infile:
        cp = ConfigParser(infile)
        items = _query_actions._list_items(cp)
        items.sort()
        assert expect == items
def test_bad_params_inside_expression():
    """Check that configuration exceptions thrown when the wrong number of arguments are used with a potentialfunction inside a
  cexprtk function"""

    cp = ConfigParser(
        io.StringIO(u"""

[Potential-Form]
bad(r) = as.buck(1.0, 2.0)
bad_parse(r) = exp() + 5.0
  
  """))
    pfr = Potential_Form_Registry(cp, register_standard=True)

    buck = pfr["as.buck"]
    buck(1000.0, 0.2, 32.0)

    with pytest.raises(Potential_Form_Exception):
        buck(1.0, 2.0)

    bad_func = pfr["bad"]()
    with pytest.raises(Potential_Form_Exception):
        bad_func(1.0)

    # Test for cexpr parse failure:
    bad_parse = pfr["bad_parse"]()
    with pytest.raises(Potential_Form_Exception):
        bad_parse(1.0)
Beispiel #11
0
def main():
    # Make a file like object from the potable input string given above.
    potable_input_file = io.StringIO(potable_input)

    # Create a Configuration() object and read input from the input file.
    configuration = Configuration()

    # This example shows how to override and add items to potable input before it
    # is passed to the Configuration object.
    #    The tabulation target will be change to 'LAMMPS'
    #    The cutoff will be reduced to 6.5
    #    An additional pair-interaction will be given for O-O

    cp = ConfigParser(
        potable_input_file,
        overrides=[
            ConfigParserOverrideTuple("Tabulation", "target", "LAMMPS"),
            ConfigParserOverrideTuple("Tabulation", "cutoff", "6.5")
        ],
        additional=[
            ConfigParserOverrideTuple("Pair", "O-O",
                                      "as.buck 444.7686 0.402 0.0")
        ])

    # Create the tabulation by passing the Config_Parser object to the Configuration.read_from_parser method.
    tabulation = configuration.read_from_parser(cp)

    # Now write tabulation to console
    tabulation.write(sys.stderr)
def test_multirange_potential_form_builder():
    # Populate potential form registry
    cp = ConfigParser(io.StringIO())
    pfr = Potential_Form_Registry(cp, register_standard=True)

    pfb = Potential_Form_Builder(pfr, Modifier_Registry())

    PFitTup = PotentialFormInstanceTuple
    MRTup = MultiRangeDefinitionTuple

    mrdefn = PFitTup(potential_form="as.zero",
                     parameters=[],
                     start=MRTup(">=", 0),
                     next=PFitTup(potential_form="as.buck",
                                  parameters=[1000.0, 0.3, 32.0],
                                  start=MRTup(">", 1),
                                  next=PFitTup(potential_form="as.constant",
                                               parameters=[3],
                                               start=MRTup(">", 5),
                                               next=None)))

    potential_func = pfb.create_potential_function(mrdefn)
    assert pytest.approx(0) == potential_func(0.0)
    v = potential_func(1.0)
    assert pytest.approx(0) == v
    v = potential_func(2.0)
    assert pytest.approx(pforms.buck(2.0, 1000.0, 0.3, 32.0)) == v
    v = potential_func(5.0)
    assert pytest.approx(pforms.buck(5.0, 1000.0, 0.3, 32.0)) == v
    assert 3.0 == potential_func(5.1)
    assert 3.0 == potential_func(10.0)
def test_filtered_config_parser_finnis_sinclair():
    lmpdir = _get_lammps_resource_dir()
    with lmpdir.join("AlFe_setfl_fs.aspot").open() as infile:
        orig_cp = ConfigParser(infile)

    filtered_cp = FilteredConfigParser(orig_cp, exclude=["Fe"])

    unfiltered = [
        "potential_form", "tabulation", "parsed_sections", "orphan_sections",
        "raw_config_parser"
    ]

    for attr in unfiltered:
        expect = getattr(orig_cp, attr)
        actual = getattr(filtered_cp, attr)
        assert DeepDiff(expect, actual) == {}

    # Now check the attributes that should be filtered
    # ... pair
    ST = SpeciesTuple
    expect = [ST("Al", "Al")]
    actual = [p[0] for p in filtered_cp.pair]
    assert DeepDiff(expect, actual) == {}

    # ... eam_embed
    expect = ["Al"]
    actual = [p[0] for p in filtered_cp.eam_embed]
    assert DeepDiff(expect, actual) == {}

    # ... eam_density
    EDST = EAMFSDensitySpeciesTuple
    expect = [EDST("Al", "Al")]
    actual = [p[0] for p in filtered_cp.eam_density_fs]
    assert DeepDiff(expect, actual) == {}
def test_orphan_sections():
    with io.open(
            _get_lammps_resource_dir().join("AlFe_setfl_fs.aspot").strpath,
            encoding="utf8") as infile:
        sio = io.StringIO(infile.read())

    sio.seek(0, os.SEEK_END)
    sio.write(u"\n\n[Charges]\nU : 2.22\nO: -1.11\n")
    sio.write(u"[Masses]\nU : 1.234\nO: 4.56\n")
    sio.seek(0)

    expect = [
        u'tabulation', u'potential_form', u'eam_embed', u'eam_density_fs',
        u'pair'
    ]
    expect.sort()

    cp = ConfigParser(sio)
    actual = cp.parsed_sections
    actual.sort()
    assert expect == actual

    actual = cp.orphan_sections
    expect = [u"Charges", u"Masses"]

    actual.sort()
    expect.sort()

    assert expect == actual
Beispiel #15
0
def test_orphan_section():
  # Check that Table-Form sections do not appear in config parser's orphan sections.
  cfgio = StringIO(example_input_1)
  cfgparser =  ConfigParser(cfgio)

  for section in cfgparser.orphan_sections:
    if section.startswith(_TableFormSection._section_name_prefix):
      pytest.fail("Section '{}' listed as an orphan section".format(section))
def test_species():
    # Test empty reference data section
    parsed = ConfigParser(io.StringIO())
    assert parsed.species == {}

    # Test reference data with overrides
    parsed = ConfigParser(
        io.StringIO(u"""
[Species]
Gd.atomic_mass = 1.234
Gd.charge = 4.567

NewSpecies.atomic_number = 600

Al.lattice_type = fcc
Al.lattice_constant = 7.8910
  
  """))

    expect = {
        u'Gd': {
            u'atomic_mass': 1.234,
            u'charge': 4.567
        },
        u'NewSpecies': {
            u'atomic_number': 600
        },
        u'Al': {
            u'lattice_type': u'fcc',
            u'lattice_constant': 7.8910
        }
    }

    actual = parsed.species

    assert DeepDiff(expect, actual) == {}

    # Test that an exception is raised if invalid syntax used

    parsed = ConfigParser(io.StringIO(u"""
[Species]
Gd : 1.234
"""))
    with pytest.raises(ConfigParserException):
        parsed.species
Beispiel #17
0
def test_tableforms_in_potentialformregistry():
  from atsim.potentials.config._potential_form_registry import Potential_Form_Registry

  cfg_string = u"""

[Table-Form:tabulated_1]
interpolation : cubic_spline
x : 0.0 0.00728 0.01455 0.02910 0.03347
y : 0.0 -3.2170 -4.6278 -2.7699 0.0

[Table-Form:tabulated_2]
interpolation : cubic_spline
x : 0 1 2 3
y : 0 1 2 3

"""

  sio = StringIO(cfg_string)
  cfg = ConfigParser(sio)
  pfr = Potential_Form_Registry(cfg, register_standard= False)
  assert pfr.registered == ["tabulated_1", "tabulated_2"]
  tabulated_2 = pfr["tabulated_2"]
  assert pytest.approx(tabulated_2()(1.0)) == 1.0

  # Now do a test to make sure other potential forms can use Table-Forms
  cfg_string = u"""

[Potential-Form]
test(r) = tabulated(r) + 5

[Table-Form:tabulated]
interpolation : cubic_spline
x : 0 1 2 3
y : 0 1 2 3

"""

  sio = StringIO(cfg_string)
  cfg = ConfigParser(sio)
  pfr = Potential_Form_Registry(cfg, register_standard= False)

  assert pfr.registered == ["tabulated", "test"]
  assert pytest.approx(pfr["tabulated"]()(1.0)) == 1.0
  assert pytest.approx(pfr["test"]()(1.0)) == 6.0
def test_indented_input_with_comment():
    single_line = u"""[Pair]
O-O : sum( as.constant 1.0, as.constant 2.0 )
  """

    expect = ConfigParser(io.StringIO(single_line)).pair
    cfg_string = u"""[Pair]
O-O : sum(
          # Interleaved comment
          as.constant
                      1.0,
          as.constant 2.0
      )
  """

    cp = ConfigParser(io.StringIO(cfg_string))
    actual = cp.pair

    assert DeepDiff(expect, actual) == {}
def test_repeat_potential_form_error():
  """Make sure error is raised if two potentials have same label"""
  cfg_string = u"""[Potential-Form]
buck(r, A, rho, C) : A*exp(-r/rho) - C/r^6
buck(r, A, rho, C,D) : A*exp(-r/rho) - C/r^6
"""
  cfg = ConfigParser(io.StringIO(cfg_string))

  with pytest.raises(Potential_Form_Registry_Exception):
    pfr = Potential_Form_Registry(cfg)
def test_config_potential_form_registry_one_potential_form():
  cfg_string = u"""[Potential-Form]
buck(r, A, rho, C) : A*exp(-r/rho) - C/r^6
"""
  cfg = ConfigParser(io.StringIO(cfg_string))
  pfr = Potential_Form_Registry(cfg)

  assert ["buck"] == pfr.registered

  buck = pfr["buck"](1000.0, 0.1, 3.0)
  assert pytest.approx(-2.9546) == buck(1.0)
def test_modifier_with_nested_modifier():
    """Test instantiation of potential forms that has a modifier that has a nested modifier in its argument list"""
    k = u"A"
    v = u"zero >=1.0 sum(nested(constant 1.0 >2 zero), buck 10.0 0.1 32.0)"

    parser = ConfigParser(io.StringIO())

    potential_forms = [
        PMT(u'nested', [
            PFI(u'constant', [1.0], MRD(u'>', 0.0),
                PFI(u'zero', [], MRD(u'>', 2), None))
        ], MRD(u'>', 0.0), None),
        PFI(u'buck', [10.0, 0.1, 32.0], MRD(u'>', 0.0), None)
    ]

    expect = PFI(u'zero', [], MRD(u'>', 0.0),
                 PMT(u'sum', potential_forms, MRD(u'>=', 1.0), None))

    expect = PairPotentialTuple(species=k, potential_form_instance=expect)
    actual = parser._parse_multi_range(k, v)
    assert DeepDiff(expect, actual) == {}
def test_pot_in_potforms_but_not_potfuncs():
  cfg = ConfigParser(io.StringIO())
  pfr = Potential_Form_Registry(cfg, True)

  # The buck4 potential is defined in potentialforms but not potentialfunctions
  # check that it's still accesible from the Potential_Form_Registry

  assert "as.buck" in pfr.registered
  assert PotentialFormSignatureTuple(label = "as.buck", parameter_names = ["r", "A", "rho", "C"], is_varargs=False) == pfr["as.buck"].signature

  assert "as.buck4" in pfr.registered
  assert PotentialFormSignatureTuple(label= "as.buck4", parameter_names = ["r", "A", "rho", "C", "r_detach", "r_min", "r_attach"], is_varargs=False) == pfr["as.buck4"].signature
def test_sum_modifier_as_part_of_multi_range():
    """Test instantiation of potential forms that use the sum() modifier as sub-range in potential definition"""
    k = u"A"
    v = u"as.constant 2.0 >=1.0 sum(as.constant 1.0 >= 2.0 as.constant 0.5, >=1.5 as.constant 10.0) >= 3.0 zero"

    parser = ConfigParser(io.StringIO())

    potential_forms = [
        PFI(u'as.constant', [1.0], MRD(u'>', 0.0),
            PFI(u'as.constant', [0.5], MRD(u'>=', 2.0), None)),
        PFI(u'as.constant', [10.0], MRD(u'>=', 1.5), None)
    ]

    expect = PFI(
        u'as.constant', [2.0], MRD(u'>', 0.0),
        PMT(u'sum', potential_forms, MRD(u'>=', 1.0),
            PFI(u'zero', [], MRD(u'>=', 3.0), None)))

    expect = PairPotentialTuple(species=k, potential_form_instance=expect)
    actual = parser._parse_multi_range(k, v)
    assert DeepDiff(expect, actual) == {}
def test_filtered_config_parser():
    lmpdir = _get_lammps_resource_dir()
    with lmpdir.join("CRG_U_Th.aspot").open() as infile:
        orig_cp = ConfigParser(infile)

    filtered_cp = FilteredConfigParser(orig_cp, exclude=["Th"])
    u_th_filtered_test(orig_cp, filtered_cp)

    filtered_cp = FilteredConfigParser(orig_cp, include=["U", "O"])
    u_th_filtered_test(orig_cp, filtered_cp)

    with pytest.raises(ValueError):
        FilteredConfigParser(orig_cp, include=["U", "O"], exclude=["Th"])
Beispiel #25
0
def test_config_parser(cfgstring):
  cfgio = StringIO(cfgstring)
  cfgparser =  ConfigParser(cfgio)

  expect = [
    TableFormTuple(
      name = u'cubic_spline',
      interpolation = u'cubic_spline',
      x = [0.0, 0.01370, 0.02740, 0.05481, 0.06303],
      y = [0.0, -2.9239, -4.2953, -2.8523, 0.0])
  ]

  actual = cfgparser.table_form
  assert DeepDiff(expect, actual) == {}
def test_list_plot_item_labels():
    expect = [
        "EAM-Embed:Th", "EAM-Embed:U", "EAM-Embed:O", "EAM-Density:Th",
        "EAM-Density:U", "EAM-Density:O", "Pair:O-O", "Pair:Th-Th", "Pair:U-U",
        "Pair:Th-O", "Pair:U-O"
    ]

    expect.sort()

    with _get_lammps_resource_dir().join("CRG_U_Th.aspot").open() as infile:
        cp = ConfigParser(infile)
        items = _query_actions._list_plot_item_labels(cp)
        items.sort()
        assert expect == items
def test_config_potential_form_registry_args():
  cfg = ConfigParser(io.StringIO())
  # import pdb; pdb.set_trace()
  pfr = Potential_Form_Registry(cfg, register_standard=True)

  buck = pfr["as.buck"]
  actual_pft = buck.signature
  expect_pft = PotentialFormSignatureTuple("as.buck", ["r", "A", "rho", "C"], False)

  assert DeepDiff(expect_pft, actual_pft) == {}

  buck = pfr["as.polynomial"]
  actual_pft = buck.signature
  expect_pft = PotentialFormSignatureTuple("as.polynomial", [], True)

  assert DeepDiff(expect_pft, actual_pft) == {}
def test_eam_density():
    """Test reading of density parameters from [EAM-Density] section"""
    cfg_string = u"""[EAM-Density]
A : density1 1000.0 0.1 1.0
B : density2 2000.0 0.2 2.0
"""
    parsed = ConfigParser(io.StringIO(cfg_string))

    expect = [
        EAMDensityTuple(
            u"A", PFI(u"density1", [1000.0, 0.1, 1.0], MRD(u">", 0.0), None)),
        EAMDensityTuple(
            u"B", PFI(u"density2", [2000.0, 0.2, 2.0], MRD(u">", 0.0), None))
    ]

    actual = parsed.eam_density
    assert DeepDiff(expect, actual) == {}
def test_list_item_labels():
    expect = [
        "Tabulation:target", "Tabulation:nr", "Tabulation:dr",
        "Tabulation:nrho", "Tabulation:drho",
        "Potential-Form:buck_morse(r,A,rho,C,D,gamma,r0)",
        "Potential-Form:density(r,n)", "EAM-Embed:Th", "EAM-Embed:U",
        "EAM-Embed:O", "EAM-Density:Th", "EAM-Density:U", "EAM-Density:O",
        "Pair:O-O", "Pair:Th-Th", "Pair:U-U", "Pair:Th-O", "Pair:U-O"
    ]

    expect.sort()

    with _get_lammps_resource_dir().join("CRG_U_Th.aspot").open() as infile:
        cp = ConfigParser(infile)
        items = _query_actions._list_item_labels(cp)
        items.sort()
        assert expect == items
def test_tabulation_cutoff_and_step():

    cfg_string = u"""[Tabulation]
cutoff : 10.0
"""

    parsed = ConfigParser(io.StringIO(cfg_string))
    assert 10.0 == parsed.tabulation.cutoff
    assert parsed.tabulation.nr is None

    cfg_string = u"""[Tabulation]
cutoff : 10.0
nr : 1000
"""

    parsed = ConfigParser(io.StringIO(cfg_string))
    assert 10.0 == parsed.tabulation.cutoff
    assert parsed.tabulation.nr == 1000

    cfg_string = u"""[Tabulation]
cutoff : 10.0
dr : 1.0
"""

    parsed = ConfigParser(io.StringIO(cfg_string))
    assert 10.0 == parsed.tabulation.cutoff
    assert parsed.tabulation.nr == 11
    assert type(parsed.tabulation.nr) is int

    cfg_string = u"""[Tabulation]
nr : 11
dr : 1.0
"""

    parsed = ConfigParser(io.StringIO(cfg_string))
    assert 10.0 == parsed.tabulation.cutoff
    assert parsed.tabulation.nr == 11

    with pytest.raises(ConfigParserException):
        cfg_string = u"""[Tabulation]
dr : 11
"""
        parsed = ConfigParser(io.StringIO(cfg_string))
        parsed.tabulation

    with pytest.raises(ConfigParserException):
        cfg_string = u"""[Tabulation]
cutoff : 10.0
dr : 0.001
nr : 11
"""
        parsed = ConfigParser(io.StringIO(cfg_string))
        parsed.tabulation