Esempio n. 1
0
def test_elegant_element_from_string_handles_arithmetic(defaults):
    drift = 'drift,l="0.04 2 /"'
    assert elegant_element_from_string("d1", drift,
                                       defaults).equals(Drift("d1", 0.02))
Esempio n. 2
0
def test_elegant_element_from_string_handles_drift(defaults):
    drift = "drift,l=0.0450000"
    assert elegant_element_from_string("d1", drift,
                                       defaults).equals(Drift("d1", 0.0450000))
Esempio n. 3
0
def test_expand_elegant():
    contents = """dmult:drift,l=1
diad6d:line=(dmult)"""
    elements = expand_elegant(contents, "diad6d", 3e9, 936)
    assert len(elements) == 1
    assert elements[0].equals(Drift("dmult", 1.0))
Esempio n. 4
0
def test_elegant_element_from_string_handles_variable(defaults):
    drift = "drift,l=a"
    defaults["a"] = 1
    correct_drift = Drift("d1", 1)
    constructed_drift = elegant_element_from_string("d1", drift, defaults)
    assert correct_drift.equals(constructed_drift)
Esempio n. 5
0
File: tracy.py Progetto: yysigari/at
def create_drift(name, params, variables):
    length = parse_float(params.pop("l", 0), variables)
    return Drift(name, length, **params)
Esempio n. 6
0
def test_expand_tracy():
    contents = "define lattice;energy=1;dmult:drift,l=1;cell:dmult;end;"
    elements, energy = expand_tracy(contents, "cell", 936)
    assert len(elements) == 1
    assert energy == 1e9
    assert elements[0].equals(Drift("dmult", 1.0))