SimonEnsemble / PorousMaterials.jl

Julia package towards classical molecular modeling of nanoporous materials
GNU General Public License v3.0
51 stars 11 forks source link

Outputing results to terminal #54

Closed mtap-research closed 5 years ago

mtap-research commented 5 years ago

This is a newbie question but I am trying to detect overlapping atoms usingPorousMaterials.jl

Thanks to PorousMaterials.atom_overlap(framework, overlap_tol=0.1)function that I can do this quickly for a large number of structures. However, the output is only shown if I am in Julia environment.

Is there a way to output "CrystalStructureName TRUE/FALSE" for a given CIF If I would like to run below Julia command in terminal? Below is a sample output that I want.

>> julia -p 4 script.jl HKUST-1.cif
HKUST-1 false
>> 
Surluson commented 5 years ago

Hi Greg,

First you would have to read in the crystal file and construct a Framework. The construction of the Framework automatically checks for overlapping atoms, but it throws an error and puts a halt to the script if it finds any overlap.

To screen a large number of structure, you could disable the "overlap check" and use the atom_overlap like you suggested. I think the following code will do what you have in mind:

list_of_filenames = ["x.cif", "y.cif", "z.cif", ...]

for filename in list_of_filename
    frame = Framework(filename, check_atom_and_charge_overlap=false)
    @printf("%s\t%s\n", frame.name, atom_overlap(frame, verbose=false))
end

This should output HKUST-1.cif false SBMOF-1.cif true etc.

For the list of filenames, you can use something like readdir("data/crystals") if you're storing your structures in data/crystals

Hope this helps, -Arni

SimonEnsemble commented 5 years ago

also no need for the -p 4 since this is coded to run on only one processor (only henry_coefficient and adsorption_isotherm are parallelized.

I'm surprised it isn't printing to the terminal... if verbose=true, which is default in the atom_overlap function, it should print a warning only if the structure has overlapping atoms. It should print out in the terminal too. Maybe it isn't printing anything because there are no overlapping atoms? Arni's method should show whether this is the case.

mtap-research commented 5 years ago

Thanks for the inputs.

I am getting atom_overlap not defined error with the suggestion based on Arni.

I made the following modification to the code and it runs and prints to the terminal.

using PorousMaterials

list_of_filenames = readdir("./")

for filename in list_of_filenames
    frame = Framework(filename, check_atom_and_charge_overlap=false)
#    @printf("%s\t%s\n", frame.name, atom_overlap(frame, verbose=false))
    @printf("%s\t%s\n", frame.name, PorousMaterials.atom_overlap(frame, verbose=false))
end