I have searched all over and can't figure out how to export data into an existing preformated file (quantum espresso input file) at a specific position.
Here is what I am trying to achieve. If the preformated file has the following structure:
&control
....
/
&system
.....
/
...
ATOMIC_POSITIONS
Si 0.0 0.0 0.0
Si 0.5 0.5 0.5
K_POINTS {automatic}
5 5 5 0 0 0
Now, I have written a small program to generate the atomic positions for a series of input files I need to create to run some QE jobs. The problema is that I have to export them first into separate files in the format shown under the ATOMIC_POSITIONS
section. Then I have to go copy paste them in each input file. I can post the way I am generating the positions but it is quite trivial.
My questions is: is it possible to generate the positions and then insert them under the ATOMIC_POSITIONS
line directly from Mathematica?
For smaller structures with small number of atoms, I can do this from bash, although is not very nice since I have to use bc
and is quite cumbersome. For larger number of atoms, becomes very laborious and I am hoping there is a Mathematica solution.
Thanks
Edit: I did some digging and I think the answer lies within string operations. However, I can't figure out how to import everything as a string and then work with lines. It would be easy if I could tell mathematica to replace all lines below the ATOMIC_POSITIONS and above K_POINTS. Within the preformatted file there is a variable that sets the number of atoms which can be used to obtain the number of lines to be replaced. I'll keep digging!
"ATOMIC_POSITIONS"
, insert your lists of positions after that point and export again $\endgroup$