impl test System #6
141
src/lib.rs
141
src/lib.rs
@@ -1,149 +1,151 @@
|
||||
|
||||
|
||||
|
||||
pub mod system{
|
||||
pub mod system {
|
||||
use crate::force::Force;
|
||||
use crate::virtual_site::VirtualSite;
|
||||
|
||||
pub struct System{}
|
||||
impl System{
|
||||
pub fn add_particle(&mut self, mass: f32){
|
||||
pub struct System {}
|
||||
impl System {
|
||||
pub fn add_particle(&mut self, _mass: f32) {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn get_num_particles(&self) -> usize{
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn get_particle_mass(&self, index: usize) -> f32{
|
||||
pub fn get_num_particles(&self) -> usize {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn set_particle_mass(&mut self, index: usize, mass: f32){
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn is_virtual_site(&self, index: usize) -> bool{
|
||||
pub fn get_particle_mass(&self, _index: usize) -> f32 {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn get_virtual_site(&self, index: usize) -> Option<Box<dyn VirtualSite>>{
|
||||
pub fn set_particle_mass(&mut self, _index: usize, _mass: f32) {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn set_virtual_site(&mut self, index: usize, vsite: Option<Box<dyn VirtualSite>>){
|
||||
pub fn is_virtual_site(&self, _index: usize) -> bool {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn add_constraint(&mut self, p1: usize, p2: usize, dist: f32){
|
||||
pub fn get_virtual_site(&self, _index: usize) -> Option<Box<dyn VirtualSite>> {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn remove_constraint(&mut self, index: usize){
|
||||
pub fn set_virtual_site(&mut self, _index: usize, _vsite: Option<Box<dyn VirtualSite>>) {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn get_num_constraints(&self) -> usize{
|
||||
pub fn add_constraint(&mut self, _p1: usize, _p2: usize, _dist: f32) {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_constraint_parameters(&self, index: usize) -> (usize, usize, f32){
|
||||
pub fn remove_constraint(&mut self, _index: usize) {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_constraint_parameters(&mut self, index: usize, p1: usize, p2: usize, dist: f32){
|
||||
pub fn get_num_constraints(&self) -> usize {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_force(&mut self, force: Box<dyn Force>){
|
||||
pub fn get_constraint_parameters(&self, _index: usize) -> (usize, usize, f32) {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_force(&mut self, index: usize){
|
||||
pub fn set_constraint_parameters(
|
||||
&mut self,
|
||||
_index: usize,
|
||||
_p1: usize,
|
||||
_p2: usize,
|
||||
_dist: f32,
|
||||
) {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_num_forces(&self) -> usize{
|
||||
pub fn add_force(&mut self, _force: Box<dyn Force>) {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_force(&self, index: usize) -> Box<dyn Force>{
|
||||
pub fn remove_force(&mut self, _index: usize) {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_num_forces(&self) -> usize {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn get_force(&self, _index: usize) -> Box<dyn Force> {
|
||||
// Todo: Rust-OpenMM
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod force{
|
||||
pub mod force {
|
||||
use std::fmt::Debug;
|
||||
|
||||
pub trait Force : Debug{}
|
||||
pub trait Force: Debug {}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct HarmonicAngleForce{}
|
||||
impl Force for HarmonicAngleForce{}
|
||||
pub struct HarmonicAngleForce {}
|
||||
impl Force for HarmonicAngleForce {}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct HarmonicBondForce{}
|
||||
impl Force for HarmonicBondForce{}
|
||||
pub struct HarmonicBondForce {}
|
||||
impl Force for HarmonicBondForce {}
|
||||
}
|
||||
|
||||
pub mod virtual_site{
|
||||
pub mod virtual_site {
|
||||
use std::fmt::Debug;
|
||||
|
||||
pub trait VirtualSite : Debug{}
|
||||
pub trait VirtualSite: Debug {}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct TwoParticleAverageSite{
|
||||
pub struct TwoParticleAverageSite {
|
||||
pub p1: usize,
|
||||
pub p2: usize,
|
||||
pub weight1: f32,
|
||||
pub weight2: f32,
|
||||
}
|
||||
impl TwoParticleAverageSite{
|
||||
pub fn new(p1: usize, p2: usize, weight1: f32, weight2: f32) -> Self{
|
||||
impl TwoParticleAverageSite {
|
||||
pub fn new(_p1: usize, _p2: usize, _weight1: f32, _weight2: f32) -> Self {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
impl VirtualSite for TwoParticleAverageSite{}
|
||||
impl VirtualSite for TwoParticleAverageSite {}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod test{
|
||||
use crate::system::System;
|
||||
mod test {
|
||||
use crate::force::{HarmonicAngleForce, HarmonicBondForce};
|
||||
use crate::system::System;
|
||||
use crate::virtual_site::TwoParticleAverageSite;
|
||||
|
||||
// Todo: Rust-OpenMM
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn test_system_particles(){
|
||||
fn test_system_particles() {
|
||||
let num_particles = 10;
|
||||
let mut system = System{};
|
||||
let mut system = System {};
|
||||
|
||||
for i in 0..num_particles{
|
||||
for i in 0..num_particles {
|
||||
system.add_particle(1.0 + 0.1 * i as f32);
|
||||
}
|
||||
system.set_particle_mass(5, 100.0);
|
||||
assert_eq!(system.get_num_particles(), num_particles);
|
||||
|
||||
for i in 0..num_particles{
|
||||
for i in 0..num_particles {
|
||||
let expected_mass = if i == 5 { 100.0 } else { 1.0 + 0.1 * i as f32 };
|
||||
assert_eq!(system.get_particle_mass(i), expected_mass);
|
||||
}
|
||||
@@ -152,18 +154,18 @@ mod test{
|
||||
// Todo: Rust-OpenMM
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn test_system_constraints(){
|
||||
fn test_system_constraints() {
|
||||
let num_particles = 10;
|
||||
let mut system = System{};
|
||||
let mut system = System {};
|
||||
|
||||
for i in 0..num_particles - 1{
|
||||
for i in 0..num_particles - 1 {
|
||||
system.add_constraint(i, i + 1, 0.2 * i as f32);
|
||||
}
|
||||
system.remove_constraint(5);
|
||||
system.set_constraint_parameters(3, 0, 5, 99.0);
|
||||
assert_eq!(system.get_num_constraints(), num_particles - 2);
|
||||
|
||||
for i in 0..num_particles - 2{
|
||||
for i in 0..num_particles - 2 {
|
||||
let (p1, p2, dist) = system.get_constraint_parameters(i);
|
||||
if i == 3 {
|
||||
assert_eq!(p1, 0);
|
||||
@@ -181,12 +183,12 @@ mod test{
|
||||
// Todo: Rust-OpenMM
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn test_system_force(){
|
||||
let mut system = System{};
|
||||
let bonds = HarmonicBondForce{};
|
||||
fn test_system_force() {
|
||||
let mut system = System {};
|
||||
let bonds = HarmonicBondForce {};
|
||||
system.add_force(Box::new(bonds));
|
||||
|
||||
let angles = HarmonicAngleForce{};
|
||||
let angles = HarmonicAngleForce {};
|
||||
system.add_force(Box::new(angles));
|
||||
|
||||
assert_eq!(system.get_num_forces(), 2);
|
||||
@@ -203,25 +205,24 @@ mod test{
|
||||
// Todo: Rust-OpenMM
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn test_system_virtual_site(){
|
||||
let mut system = System{};
|
||||
fn test_system_virtual_site() {
|
||||
let mut system = System {};
|
||||
let num_particles = 10;
|
||||
for i in 0..num_particles{
|
||||
for i in 0..num_particles {
|
||||
system.add_particle(1.0);
|
||||
assert!(!system.is_virtual_site(i));
|
||||
}
|
||||
|
||||
let vsite = TwoParticleAverageSite::new(2, 3, 0.4, 0.6);
|
||||
system.set_virtual_site(4, Some(Box::new(vsite)));
|
||||
for i in 0..num_particles{
|
||||
for i in 0..num_particles {
|
||||
assert_eq!(system.is_virtual_site(i), i == 4);
|
||||
}
|
||||
// Todo: Rust-OpenMM
|
||||
// assert_eq!(system.get_virtual_site(4), Some(Box::new(vsite)));
|
||||
system.set_virtual_site(4, None);
|
||||
for i in 0..num_particles{
|
||||
for i in 0..num_particles {
|
||||
assert!(!system.is_virtual_site(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user