-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add packaging instructions * Add ./cargo to gitignore * Add build instructions * Separate API * Add README
- Loading branch information
Showing
23 changed files
with
192 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
/target | ||
**target/ | ||
**.DS_Store | ||
**/.idea | ||
**build | ||
/Cargo.lock | ||
**Cargo.lock | ||
.env/ | ||
examples/*opt.xyz | ||
.cargo/ | ||
api/examples/*opt.xyz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,15 @@ | ||
[package] | ||
name = "mors" | ||
name = "optrs" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Tom Young"] | ||
|
||
|
||
[lib] | ||
name = "mors" | ||
crate-type = ["cdylib"] | ||
[[bin]] | ||
name = "optrs" | ||
path = "src/main.rs" | ||
|
||
[dependencies] | ||
clap = { version = "3.1.6", features = ["derive"] } | ||
log = "0.4" | ||
rand = "0.8.5" | ||
pyo3 = { version = "0.16.3", features = ["extension-module"] } | ||
|
||
|
||
[profile.release] | ||
debug = 1 | ||
pyo3 = { version = "0.16.5", features = ["extension-module"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,33 @@ | ||
mors | ||
[![Test](https://github.com/t-young31/opt-rs/actions/workflows/test.yml/badge.svg)](https://github.com/t-young31/opt-rs/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/t-young31/mors/branch/main/graph/badge.svg?token=5KTYG2WJ9L)](https://codecov.io/gh/t-young31/mors) | ||
|
||
![alt text](src/common/logo.png) | ||
|
||
**optrs** is a lightweight molecular mechanics optimisation code written in rust. | ||
|
||
*** | ||
### Installation | ||
Install the binary with | ||
|
||
```bash | ||
pip install optrs | ||
``` | ||
|
||
or the [Python API](https://github.com/t-young31/opt-rs/tree/main/api). | ||
|
||
*** | ||
### Usage | ||
Optimise a molecule provided as a [.xyz](https://en.wikipedia.org/wiki/XYZ_file_format) file | ||
|
||
```bash | ||
optrs molecule.xyz | ||
``` | ||
|
||
which will generate _opt.xyz_ in working directory. | ||
[API examples](https://github.com/t-young31/opt-rs/tree/main/api/examples). | ||
|
||
*** | ||
### Features | ||
- [UFF](https://doi.org/10.1021/ja00051a040) forcefield | ||
- [RB](https://doi.org/10.1002/anie.202011941) forcefield | ||
- 3D structure generation | ||
- Steepest decent optimisation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "optrs" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Tom Young"] | ||
|
||
[lib] | ||
path = "../src/lib.rs" | ||
name = "optrs" | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
clap = { version = "3.1.6", features = ["derive"] } | ||
log = "0.4" | ||
rand = "0.8.5" | ||
pyo3 = { version = "0.16.5", features = ["extension-module"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
### Python API | ||
|
||
*** | ||
Install with | ||
|
||
```bash | ||
pip install optrs-api | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
"""Optimise a structure using the default (UFF) forcefield:""" | ||
import mors | ||
import optrs | ||
|
||
mol = mors.Molecule.from_xyz_file("metallocage.xyz") | ||
mol = optrs.Molecule.from_xyz_file("metallocage.xyz") | ||
mol.optimise() | ||
mol.write_xyz_file("metallocage_opt.xyz") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
### Development documentation | ||
|
||
#### Packaging | ||
Linux wheels are built using the maturin manylinux docker container with | ||
|
||
```bash | ||
docker run -it --rm -v $(pwd):/io --entrypoint bash ghcr.io/pyo3/maturin:main | ||
maturin build --release --strip --interpreter python3.7 python3.8 python3.9 python3.10 | ||
``` | ||
|
||
while macOS wheels are generated with | ||
```bash | ||
./dev/build_mac_wheels.sh | ||
``` | ||
|
||
Upload to TestPyPI first with | ||
```bash | ||
python3 -m twine upload --repository testpypi target/wheels/* | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash -l | ||
|
||
for minor_version in {8..10}; do | ||
conda create -n test "python=3.$minor_version" --yes | ||
conda activate test | ||
pip install maturin | ||
maturin build --release --strip --universal2 | ||
conda deactivate | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use clap::Parser; | ||
|
||
use crate::molecule::Molecule; | ||
use crate::ff::forcefield::Forcefield; | ||
use crate::ff::rb::core::RB; | ||
use crate::ff::uff::core::UFF; | ||
|
||
|
||
#[derive(Parser, Debug)] | ||
#[clap(author, version, about, long_about = None)] | ||
pub struct CommandLineArguments { | ||
#[clap(index = 1)] | ||
xyz_filename: String, | ||
|
||
#[clap(short, long, default_value="UFF")] | ||
forcefield: String, | ||
} | ||
|
||
|
||
pub fn run(args: CommandLineArguments) { | ||
|
||
let mut mol = Molecule::from_xyz_file(&args.xyz_filename); | ||
|
||
match args.forcefield.as_str() { | ||
"UFF" => mol.optimise(&mut UFF::new(&mol)), | ||
"RB" => mol.optimise(&mut RB::new(&mol)), | ||
_ => panic!("Cannot set a forcefield. Unknown type") | ||
} | ||
|
||
mol.write_xyz_file("opt.xyz"); | ||
} | ||
|
||
|
||
|
||
/* | ||
/$$ /$$ | ||
| $$ | $$ | ||
/$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$ | ||
|_ $$_/ /$$__ $$ /$$_____/|_ $$_/ /$$_____/ | ||
| $$ | $$$$$$$$| $$$$$$ | $$ | $$$$$$ | ||
| $$ /$$| $$_____/ \____ $$ | $$ /$$\____ $$ | ||
| $$$$/| $$$$$$$ /$$$$$$$/ | $$$$//$$$$$$$/ | ||
\___/ \_______/|_______/ \___/ |_______/ | ||
*/ | ||
|
||
#[cfg(test)] | ||
mod tests{ | ||
|
||
use super::*; | ||
use crate::utils::*; | ||
|
||
#[test] | ||
fn test_simple_cli(){ | ||
|
||
let filename = "h2_tscli.xyz"; | ||
print_dihydrogen_xyz_file(filename); | ||
|
||
let args = CommandLineArguments{xyz_filename: filename.to_string(), | ||
forcefield: "UFF".to_string()}; | ||
run(args); | ||
|
||
remove_file_or_panic(filename); | ||
remove_file_or_panic("opt.xyz") | ||
} | ||
|
||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.