use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub enum Command {
InitForceEnv { input: String, output: String },
InitForceEnvWithGeometry {
input: String,
output: String,
symbols: Vec<String>,
positions_angstrom: Vec<f64>,
cell_angstrom: Vec<f64>,
periodic: String,
},
CalcEnergyForce,
CalcEnergy,
GetNatom,
GetNparticle,
GetPositions,
GetForces,
GetPotentialEnergy,
GetCell,
GetQmmmCell,
SetPositions { data: Vec<f64> },
SetVelocities { data: Vec<f64> },
SetCell { data: Vec<f64> },
GetMoCount,
#[cfg(feature = "extended")]
IsQuickstep,
#[cfg(feature = "extended")]
GetStressTensor,
#[cfg(feature = "extended")]
GetVirialTensor,
#[cfg(feature = "extended")]
GetNmo { spin: i32 },
#[cfg(feature = "extended")]
GetEigenvalues { spin: i32 },
#[cfg(feature = "extended")]
GetOccupationNumbers { spin: i32 },
#[cfg(feature = "extended")]
GetHomoLumo { spin: i32 },
#[cfg(feature = "extended")]
GetMullikenCharges,
#[cfg(feature = "extended")]
GetHirshfeldCharges,
#[cfg(feature = "extended")]
GetDipoleMoment,
#[cfg(feature = "extended")]
GetScfInfo,
#[cfg(feature = "extended")]
GetEnergyComponents,
#[cfg(feature = "extended")]
GetNelectron,
#[cfg(feature = "extended")]
GetFermiEnergy,
#[cfg(feature = "extended")]
GetTotalSpin,
Shutdown,
GetVersion,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Request {
pub request_id: u64,
pub command: Command,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum Status {
Ok,
Error(String),
}
#[derive(Debug, Serialize, Deserialize)]
pub enum Payload {
Empty,
Int(i64),
UInt(u64),
Float(f64),
Bool(bool),
Array1(Vec<f64>),
Array2 {
rows: usize,
cols: usize,
data: Vec<f64>,
},
String(String),
HomoLumo {
homo: f64,
lumo: f64,
homo_idx: i32,
lumo_idx: i32,
},
EnergyComponents {
e_kin: f64,
e_hartree: f64,
e_xc: f64,
e_core: f64,
e_total: f64,
},
ScfInfo {
nsteps: i32,
converged: bool,
energy_change: f64,
},
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Response {
pub request_id: u64,
pub status: Status,
pub payload: Payload,
}
impl Response {
pub fn ok(request_id: u64, payload: Payload) -> Self {
Response {
request_id,
status: Status::Ok,
payload,
}
}
pub fn error(request_id: u64, msg: impl Into<String>) -> Self {
Response {
request_id,
status: Status::Error(msg.into()),
payload: Payload::Empty,
}
}
}