aestimosolver / aestimo

Aestimo 1D Schrödinger-Poisson Solver
https://aestimosolver.github.io
GNU General Public License v3.0
52 stars 23 forks source link

Any example file must run in any folder. #10

Closed sblisesivdin closed 4 years ago

sblisesivdin commented 4 years ago

In the current state, aestimo can run the input files only in the main folder. If you need to run any input, you must copy it to main folder.

We need something better. The easy way can be including examples/ folder information into the config file. But again, the input files can run only in one folder.

Other methods: writing a parser to aestimo. With a parser, we can send options and arguments like:

./aestimo_eh.py -i <input_file> -o <output_dir>

In this case, there will be no need for including the input file name in config.py

h-hebal commented 4 years ago

Adding these lines solves the issue: from os import path if name == "main": #this code allows you to run the input file directly input_obj = vars() import sys sys.path.append(path.join(path.dirname(file), '..')) import aestimo_eh aestimo_eh.run_aestimo(input_obj)

h-hebal commented 4 years ago

Still, you have to change the config.py file with the name of the running example (only to create its folder) but afterwards, you only run the example file not aestimo.py or aestimo_eh.py.

h-hebal commented 4 years ago

-Suggested solution -Filename variable is moved to the target example instead of config.py file to enable the creation of its own folder after direct execution of the target example file. -Changes are made only for testing until full approval.