pub(crate) fn lammps_disp_fn(&self, coords: &Coords, meta: M) -> FailResult<Box<dyn DispFn>>
    {
        struct MyDispFn<Q: LammpsPotential>(::rsp2_lammps_wrap::DispFn<Q>);
        impl<Mm: Clone + 'static, Q: LammpsPotential<Meta=Mm>> DispFn for MyDispFn<Q> {
            fn compute_sparse_force_delta(&mut self, disp: (usize, V3)) -> FailResult<BTreeMap<usize, V3>>
            {
                let orig_force = self.0.equilibrium_force();
                let final_force = self.0.compute_force_at_disp(disp)?;
                Ok(helper::sparse_deltas_from_dense_deterministic(&orig_force, &final_force))
            }
        }

        // (panic on lock already acquired; blocking could easily deadlock)
        let lock = INSTANCE_LOCK.try_lock().expect("Tried to construct multiple Lammps instances in parallel");

        let lmp_disp_fn = self.inner.build_disp_fn(lock, self.potential.clone(), coords.clone(), meta)?;
        Ok(Box::new(MyDispFn(lmp_disp_fn)) as Box<_>)
    }
// For displacements, we delegate the computation to ::rsp2_lammps_wrap::DispFn,
// which communicates data to lammps in a different manner which is optimized specifically
// for this purpose. (basically guaranteeing no neighbor list rebuilds)
For displacements, we delegate the computation to ::rsp2_lammps_wrap::DispFn,
which communicates data to lammps in a different manner which is optimized specifically
for this purpose. (basically guaranteeing no neighbor list rebuilds)
For displacements we delegate the computation to :: rsp2_lammps_wrap :: DispFn which communicates data to lammps in a different manner which is optimized specifically for this purpose . ( basically guaranteeing no neighbor list rebuilds )
pub(crate) fn lammps_disp_fn(&self, coords: &Coords, meta: M) -> FailResult<Box<dyn DispFn>>
    {
        struct MyDispFn<Q: LammpsPotential>(::rsp2_lammps_wrap::DispFn<Q>);
        impl<Mm: Clone + 'static, Q: LammpsPotential<Meta=Mm>> DispFn for MyDispFn<Q> {
            fn compute_sparse_force_delta(&mut self, disp: (usize, V3)) -> FailResult<BTreeMap<usize, V3>>
            {
                let orig_force = self.0.equilibrium_force();
                let final_force = self.0.compute_force_at_disp(disp)?;
                Ok(helper::sparse_deltas_from_dense_deterministic(&orig_force, &final_force))
            }
        }
        // (panic on lock already acquired; blocking could easily deadlock)
        let lock = INSTANCE_LOCK.try_lock().expect("Tried to construct multiple Lammps instances in parallel");
        let lmp_disp_fn = self.inner.build_disp_fn(lock, self.potential.clone(), coords.clone(), meta)?;
        Ok(Box::new(MyDispFn(lmp_disp_fn)) as Box<_>)
    }
pub ( crate ) fn lammps_disp_fn ( & self , coords : & Coords , meta : M ) -> FailResult < Box < dyn DispFn > > { struct MyDispFn < Q : LammpsPotential > ( :: rsp2_lammps_wrap :: DispFn < Q > ) ; impl < Mm : Clone + ' static , Q : LammpsPotential < Meta = Mm > > DispFn for MyDispFn < Q > { fn compute_sparse_force_delta ( & mut self , disp : ( usize , V3 ) ) -> FailResult < BTreeMap < usize , V3 > > { let orig_force = self . 0 . equilibrium_force ( ) ; let final_force = self . 0 . compute_force_at_disp ( disp ) ? ; Ok ( helper :: sparse_deltas_from_dense_deterministic ( & orig_force , & final_force ) ) } } // (panic on lock already acquired; blocking could easily deadlock) let lock = INSTANCE_LOCK . try_lock ( ) . expect ( " " ) ; let lmp_disp_fn = self . inner . build_disp_fn ( lock , self . potential . clone ( ) , coords . clone ( ) , meta ) ? ; Ok ( Box :: new ( MyDispFn ( lmp_disp_fn ) ) as Box < _ > ) }
For displacements, we delegate the computation to ::rsp2_lammps_wrap::DispFn,
which communicates data to lammps in a different manner which is optimized specifically
for this purpose.
For displacements we delegate the computation to :: rsp2_lammps_wrap :: DispFn which communicates data to lammps in a different manner which is optimized specifically for this purpose .
&self
coords
&Coords
meta
M
&self
coords
&Coords
meta
M