Open DanielDewitt opened 8 months ago
Okay so one workaround I found is if you define the input in the astra input file (e.g. astra.in) as vectors without brackets as stated before then the input parser will recognize the number as such.
Then you only have to modify namelist_lines() in writers.py where vectors are handled (elif type(value) == type([])
) and change the way the namelist lines are created by including the round brackets.
Not sure if this is the best way but it worked for me.
@DanielDewitt Could you post complete reproducible input for this example?
Sure, of course. Here's a stripped down version, tested both the error and the workaround. Code was also the bare minimum:
A0 = Astra("astra.in")
A0.timeout = None
A0.verbose = True
A0.run()
Daniel Hi,I have encountered the same program problem as you. Can you explain your solution in detail? Or I can look at your modified namelist_lines() in writer.py. It means a lot to me. Thank you so much Thanks, Yuxin
Hi Yuxin, sure, since it's just two lines of code I think it's best I just post it here. I replaced this (lines 31/32 in astra/writers.py)
liststr += str(item) + ' '
line = key + ' = ' + liststr
with this
liststr += str(item) + ','
line = key + ' = ' + "(" + liststr[:-1] + ")"
Then when you define the dipole coordinates use no brackets at all, just the two coordinates separated by a comma. It didn't break anything else for me as far as I know. Let me know if this works, it's been some time so maybe I forgot something.
BR Daniel
Hi Yuxin, 您好 Yuxin, sure, since it's just two lines of code I think it's best I just post it here. I replaced this (lines 31/32 in astra/writers.py)当然,既然只有两行代码,我认为我最好把它贴在这里。我替换了这个(astra/writers.py 中的 31/32 行)
liststr += str(item) + ' '
line = key + ' = ' + liststr ``行 = 键 + ' = ' + liststr
with this 有了这个
liststr += str(item) + ','
line = key + ' = ' + "(" + liststr[:-1] + ")"
Then when you define the dipole coordinates use no brackets at all, just the two coordinates separated by a comma. It didn't break anything else for me as far as I know. Let me know if this works, it's been some time so maybe I forgot something.然后,当您定义偶极坐标时,根本不使用括号,只使用用逗号分隔的两个坐标。据我所知,它并没有破坏我的任何其他东西。让我知道这是否有效,已经有一段时间了,所以也许我忘记了什么。
BR BR 餐厅 Daniel 丹尼尔
Hi Daniel,
Thanks a lot for your help with the program issue. Your solution worked perfectly! I really appreciate your assistance.
Best, Yuxin
@DanielDewitt would you be able to make a PR with this fix?
@ChristopherMayes Sure, sorry for the delay.
Hi,
I'm having an issue when using the &Dipole namelist. When setting up the 4 dipole coordinates Astra expects something like:
d1(1) = (1.0, 0.6)
Apparently the namelist parser as a problem with the brackets in the value input which leads to the value being passed as a string which is then passed (I suppose) by the CommandWrapper to Astra, leading to an error when reading the dipole parameters.
Leaving out the brackets leads to the parser recognizing the value as a vector and stores the numbers accordingly:
d1(1)': [1, 0.6]
The problem then is that Astra stores the content of the array as two separate sets of double complex arrays. I suppose the easiest way would be to change the way the CommandWrapper hands the vector input to Astra but I haven't found a way yet.
Thanks, Daniel