fn sanity_check(system: &System) {
    for position in system.particles().position {
        // The value of 1e6 A should be a good enough threshold. Even with
        // big boxes (100 A), and going through the boxes multiple time,
        // the particles positions should stay bellow this point.
        if any(position, |x| x.abs() > 1e6) {
            warn!(
                "Some particles have moved very far from the origin, \
                 the simulation might be exploding"
            );
            // we don't want to spam the output, so we return early if a
            // problem was found
            return;
        }
    }

    for velocity in system.particles().velocity {
        // Velocity threshold is 1000 A / fs
        if any(velocity, |x| x.abs() > 1000.0) {
            warn!(
                "Some particles have a very high velocity, \
                 the simulation might be exploding"
            );
            return;
        }
    }
}
/// Perform some sanity checks on the system
Perform some sanity checks on the system
Perform some sanity checks on the system
fn sanity_check(system: &System) {
    for position in system.particles().position {
        // The value of 1e6 A should be a good enough threshold. Even with
        // big boxes (100 A), and going through the boxes multiple time,
        // the particles positions should stay bellow this point.
        if any(position, |x| x.abs() > 1e6) {
            warn!(
                "Some particles have moved very far from the origin, \
                 the simulation might be exploding"
            );
            // we don't want to spam the output, so we return early if a
            // problem was found
            return;
        }
    }
    for velocity in system.particles().velocity {
        // Velocity threshold is 1000 A / fs
        if any(velocity, |x| x.abs() > 1000.0) {
            warn!(
                "Some particles have a very high velocity, \
                 the simulation might be exploding"
            );
            return;
        }
    }
}
fn sanity_check ( system : & System ) { for position in system . particles ( ) . position { // The value of 1e6 A should be a good enough threshold. Even with // big boxes (100 A), and going through the boxes multiple time, // the particles positions should stay bellow this point. if any ( position , | x | x . abs ( ) > 1e6 ) { warn ! ( " \
 " ) ; // we don't want to spam the output, so we return early if a // problem was found return ; } } for velocity in system . particles ( ) . velocity { // Velocity threshold is 1000 A / fs if any ( velocity , | x | x . abs ( ) > 1000.0 ) { warn ! ( " \
 " ) ; return ; } } }
Perform some sanity checks on the system
Perform some sanity checks on the system
system
&System