bmad-sim / bmad-ecosystem

Bmad simulation ecosystem for simulating high energy storage rings.
https://www.classe.cornell.edu/bmad/
12 stars 13 forks source link

In evaluating expressions with data::, tao runs into trouble if there is a multiplication operator before data:: #1155

Closed jsberg-bnl closed 1 month ago

jsberg-bnl commented 1 month ago

Here's an example to work with: 240816a.zip; start with tao -init 240816a.init. Having a * before data:: causes somewhat odd and rather random-looking behavior:

Tao> sho val data::mf.xm|model
    1:   -4.0768036614048118E-02     MF (3)
    2:   -4.0321001204109967E-02     MF (3)
    3:   -3.8997123998910414E-02     MF (3)
    4:   -3.6801787533221747E-02     MF (3)
    5:   -3.3743917624790107E-02     MF (3)
    6:   -2.9835947261543205E-02     MF (3)
    7:   -2.5093766207261711E-02     MF (3)
    8:   -1.9536656620047874E-02     MF (3)
    9:   -1.3187214963569741E-02     MF (3)
Tao> sho val 3*data::mf.xm|model
[ERROR | 2024-AUG-16 18:28:34] tao_find_data:
    Couldn't find data: 3*data::mf.xm|model
[ERROR | 2024-AUG-16 18:28:34] tao_evaluate_expression:
    ERROR IN EXPRESSION: 3*data::mf.xm|model
    CANNOT EVALUATE: 3*data::mf.xm|model
Tao> sho val data::mf.xm|model*3
    1:   -1.2230410984214435E-01     MF (3)
    2:   -1.2096300361232989E-01     MF (3)
    3:   -1.1699137199673124E-01     MF (3)
    4:   -1.1040536259966524E-01     MF (3)
    5:   -1.0123175287437032E-01     MF (3)
    6:   -8.9507841784629616E-02     MF (3)
    7:   -7.5281298621785134E-02     MF (3)
    8:   -5.8609969860143621E-02     MF (3)
    9:   -3.9561644890709222E-02     MF (3)
Tao> sho val data::mf.xm|model*ele::mf##1[b1_gradient]
    1:   -1.7694405156986528E+02     MF (3)
    2:   -1.7500379976479326E+02     MF (3)
    3:   -1.6925782286905337E+02     MF (3)
    4:   -1.5972948250585398E+02     MF (3)
    5:   -1.4645751908279780E+02     MF (3)
    6:   -1.2949589505281963E+02     MF (3)
    7:   -1.0891357618948547E+02     MF (3)
    8:   -8.4794252154132622E+01     MF (3)
    9:   -5.7235997570036012E+01     MF (3)
Tao> sho val ele::mf##1[b1_gradient]*data::mf.xm|model
     4.3402642429165280E+03
DavidSagan commented 1 month ago

Fixed.