ashtonmv / sphinx_input

Collaboration for SPHInX input representations
0 stars 0 forks source link

convenience function for adding single settings with full "path" #1

Open freyso opened 4 years ago

freyso commented 4 years ago

I think it would be cool to have some convenience function like: sphinx_base.addSetting ("PAWHamiltonian/dipoleCorrection") or sphinx_base.addSetting ("/main/scfDiag/blockCG/nSloppy", 10) or sphinx_base.addSetting("main.scfDiag.blockCG.nSloppy", 10) (edited)

jan-janssen commented 4 years ago

Or alternatively:

sphinx_base.input["PAWHamiltonian/dipoleCorrection"]
sphinx_base.input["/main/scfDiag/blockCG/nSloppy"] = 10
sphinx_base.input.main.scfDiag.blockCG.nSloppy = 10
freyso commented 4 years ago

For the flags, I'd probably prefer something like sphinx_base.input["PAWHamiltonian/dipoleCorrection"] = True otherwise it is hard to see that this line of code is "setting" something.

But Jan, I have some question: is input meant to be a container that is parsed at the time when the input file is written/generated? Or does it already contain internally Sam's representation?

jan-janssen commented 4 years ago

Yes, the idea was editing Sam's internal structure before it is written.

ashtonmv commented 4 years ago

as of my latest push, sphinx_base.input["PAWHamiltonian/dipoleCorrection"] is still not possible, but sphinx_base.input.main.scfDiag... etc is.

All possible groups are loaded into sphinx_base.input by default: species, structure, basis, hamiltonian, guess, spin, and main. They are created as class Group, which is basically an extended python dictionary that has some of the functions, e.g. dot notation, that we wanted. Flags are set/unset as booleans, like @freyso suggested.

When sphinx_base.write_input() is called, the contents of all groups are parsed to their respective SPHInX-identifiable filenames, and listed in input.sx (the main wrapper).

I loaded pyiron into this repository so it can be tested via creating real pyiron jobs. sphinx_input.ipynb still gives usage examples. I know I've broken several pyiron sphinx tests by changing the representation/ filenames, but the tests can be easily amended if we think this representation is plausible.