Skip to content

Commit

Permalink
import neb codes from gosh
Browse files Browse the repository at this point in the history
  • Loading branch information
ybyygu committed Feb 8, 2019
1 parent de23f4d commit 5f881fe
Show file tree
Hide file tree
Showing 4 changed files with 654 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# cargo

# [[file:~/Workspace/Programming/gosh/nebrun/neb.note::*cargo][cargo:1]]
[package]
name = "neb"
version = "0.0.1"
edition = "2018"
authors = ["Wenping Guo <[email protected]>"]

[dependencies]
quicli = "0.4"
structopt = "0.2"
#gosh = {git = "https://github.com/gosh-rs/gosh.git", tag="v0.0.17"}
gosh = {path = "/home/ybyygu/Workspace/Programming/gosh"}

[dev-dependencies]
approx = "0.3"
# cargo:1 ends here
61 changes: 61 additions & 0 deletions src/bin/nebrun.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// entry

use gosh::cmd_utils::*;
use std::path::PathBuf;

use gosh::gchemol::io;

use neb::NEB;
use gosh::models::*;

/// An universal runner for Blackbox Model
#[derive(Debug, StructOpt)]
struct Cli {
/// Input molecule file
#[structopt(parse(from_os_str))]
molfile: PathBuf,

/// Template directory with all related files. The default is current directory.
#[structopt(short = "t", long = "template-dir", parse(from_os_str))]
tpldir: Option<PathBuf>,

/// Output the caputured structure. e.g.: -o foo.xyz
#[structopt(short = "o", long = "output", parse(from_os_str))]
output: Option<PathBuf>,

#[structopt(flatten)]
verbosity: Verbosity,
}

fn main() -> CliResult {
let args = Cli::from_args();
args.verbosity.setup_env_logger(&env!("CARGO_PKG_NAME"))?;

// 1. load molecules
info!("input molecule file: {}", &args.molfile.display());
let mut mols = io::read(args.molfile)?;
info!("loaded {} molecules.", mols.len());

let bbm = if let Some(d) = args.tpldir {
BlackBox::from_dotenv(&d)
} else {
BlackBox::default()
};

let mut neb = NEB::new(mols);

neb.run(&bbm)?;

// output molecules
if let Some(path) = args.output {
let mut mols = vec![];
for image in neb.images {
mols.push(image.mol.clone());
}

println!("file saved to: {:}", path.display());
io::write(path, &mols)?;
}

Ok(())
}
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// mods

// [[file:~/Workspace/Programming/gosh/nebrun/neb.note::*mods][mods:1]]
mod neb;

pub use crate::neb::NEB;
// mods:1 ends here

// base

// [[file:~/Workspace/Programming/gosh/nebrun/neb.note::*base][base:1]]
pub(crate) mod common {
pub use quicli::prelude::*;
pub type Result<T> = ::std::result::Result<T, Error>;
}
// base:1 ends here
Loading

0 comments on commit 5f881fe

Please sign in to comment.