Skip to content

Commit

Permalink
Implement arrow separation logic and two phases of the dynamic simula…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
stfnp committed Sep 13, 2024
1 parent 4b63b1a commit cef92f5
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 59 deletions.
5 changes: 3 additions & 2 deletions solver/bows/tests/saved.bow
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"n_string_elements": 1,
"n_draw_steps": 100,
"arrow_clamp_force": 0.5,
"time_span_factor": 1.5,
"time_step_factor": 0.2,
"timespan_factor": 1.5,
"timestep_factor": 0.2,
"timeout_factor": 5.0,
"sampling_rate": 10000.0
},
"dimensions": {
Expand Down
5 changes: 3 additions & 2 deletions solver/bows/tests/valid.bow
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"n_string_elements": 25,
"n_draw_steps": 150,
"arrow_clamp_force": 0.0,
"time_span_factor": 1.5,
"time_step_factor": 0.2,
"timespan_factor": 1.5,
"timestep_factor": 0.2,
"timeout_factor": 5.0,
"sampling_rate": 10000.0
},
"dimensions": {
Expand Down
8 changes: 4 additions & 4 deletions solver/bows/users/69w865k9.bow
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@
"height": [
[
0.0,
0.0415
0.038
],
[
0.05,
0.0214
0.018600000000000002
],
[
0.1,
0.009
0.0067
],
[
0.15,
0.002
0.0008
],
[
0.18,
Expand Down
5 changes: 3 additions & 2 deletions solver/bows/versions/v0/v3.bow
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"n_string_elements": 25,
"n_draw_steps": 150,
"arrow_clamp_force": 0.0,
"time_span_factor": 1.5,
"time_step_factor": 0.2,
"timespan_factor": 1.5,
"timestep_factor": 0.2,
"timeout_factor": 5.0,
"sampling_rate": 10000.0
},
"dimensions": {
Expand Down
5 changes: 3 additions & 2 deletions solver/bows/versions/v2/v3.bow
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"n_string_elements": 25,
"n_draw_steps": 150,
"arrow_clamp_force": 0.0,
"time_span_factor": 1.5,
"time_step_factor": 0.2,
"timespan_factor": 1.5,
"timestep_factor": 0.2,
"timeout_factor": 5.0,
"sampling_rate": 10000.0
},
"dimensions": {
Expand Down
5 changes: 5 additions & 0 deletions solver/src/bow/compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ fn convert_v2_to_v3(value: &mut Value) -> Result<(), ModelError> {
// New settings entries for number of evaluation points
value["settings"]["n_limb_eval_points"] = json!(100);
value["settings"]["n_layer_eval_points"] = json!(100);
value["settings"]["timeout_factor"] = json!(5.0);

// Renamed settings
value["settings"]["timespan_factor"] = json!(value["settings"]["time_span_factor"]);
value["settings"]["timestep_factor"] = json!(value["settings"]["time_step_factor"]);

// Move width to width/points
value["width"] = json!({
Expand Down
6 changes: 4 additions & 2 deletions solver/src/bow/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub enum ModelError {
SettingsInvalidArrowClampForce(f64),
SettingsInvalidTimeSpanFactor(f64),
SettingsInvalidTimeStepFactor(f64),
SettingsInvalidTimeOutFactor(f64),
SettingsInvalidSamplingRate(f64),

DimensionsInvalidBraceHeight(f64),
Expand Down Expand Up @@ -121,8 +122,9 @@ impl Display for ModelError {
ModelError::SettingsInvalidStringElements(value) => write!(f, "Settings: Number of string elements must be at least 1 but actual number is {value}.")?,
ModelError::SettingsInvalidDrawSteps(value) => write!(f, "Settings: Number of draw steps must be at least 1 but actual number is {value}.")?,
ModelError::SettingsInvalidArrowClampForce(value) => write!(f, "Settings: Arrow clamp force must be a non-negative number but actual value is {value}.")?,
ModelError::SettingsInvalidTimeSpanFactor(value) => write!(f, "Settings: Time span factor must be a non-negative number but actual value is {value}.")?,
ModelError::SettingsInvalidTimeStepFactor(value) => write!(f, "Settings: Time step factor must be a non-negative number but actual value is {value}.")?,
ModelError::SettingsInvalidTimeSpanFactor(value) => write!(f, "Settings: Timespan factor must be a non-negative number but actual value is {value}.")?,
ModelError::SettingsInvalidTimeStepFactor(value) => write!(f, "Settings: Timestep factor must be a non-negative number but actual value is {value}.")?,
ModelError::SettingsInvalidTimeOutFactor(value) => write!(f, "Settings: Timeout factor must be a non-negative number but actual value is {value}.")?,
ModelError::SettingsInvalidSamplingRate(value) => write!(f, "Settings: Sampling rate must be a positive number but actual value is {value}.")?,

ModelError::DimensionsInvalidBraceHeight(value) => write!(f, "Dimensions: Brace height must be a finite number, actual value is {value}.")?,
Expand Down
21 changes: 13 additions & 8 deletions solver/src/bow/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ impl Default for BowInput {
n_string_elements: 1, // TODO
n_draw_steps: 100,
arrow_clamp_force: 0.5,
time_span_factor: 1.5,
time_step_factor: 0.2,
timespan_factor: 1.5,
timestep_factor: 0.2,
timeout_factor: 5.0,
sampling_rate: 10000.0
},
dimensions: Dimensions {
Expand Down Expand Up @@ -144,8 +145,9 @@ pub struct Settings {
pub n_string_elements: usize,
pub n_draw_steps: usize,
pub arrow_clamp_force: f64,
pub time_span_factor: f64,
pub time_step_factor: f64,
pub timespan_factor: f64,
pub timestep_factor: f64,
pub timeout_factor: f64,
pub sampling_rate: f64
}

Expand All @@ -169,11 +171,14 @@ impl Settings {
if !self.arrow_clamp_force.is_finite() || self.arrow_clamp_force < 0.0 {
return Err(ModelError::SettingsInvalidArrowClampForce(self.arrow_clamp_force));
}
if !self.time_span_factor.is_finite() || self.time_span_factor < 0.0 {
return Err(ModelError::SettingsInvalidTimeSpanFactor(self.time_span_factor));
if !self.timespan_factor.is_finite() || self.timespan_factor < 0.0 {
return Err(ModelError::SettingsInvalidTimeSpanFactor(self.timespan_factor));
}
if !self.time_step_factor.is_finite() || self.time_step_factor < 0.0 {
return Err(ModelError::SettingsInvalidTimeStepFactor(self.time_step_factor));
if !self.timestep_factor.is_finite() || self.timestep_factor < 0.0 {
return Err(ModelError::SettingsInvalidTimeStepFactor(self.timestep_factor));
}
if !self.timeout_factor.is_finite() || self.timeout_factor < 0.0 {
return Err(ModelError::SettingsInvalidTimeOutFactor(self.timeout_factor));
}
if !self.sampling_rate.is_finite() || self.sampling_rate <= 0.0 {
return Err(ModelError::SettingsInvalidSamplingRate(self.sampling_rate));
Expand Down
Loading

0 comments on commit cef92f5

Please sign in to comment.