Skip to content

Commit

Permalink
Quarter Car update
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhjp01 committed Feb 22, 2023
1 parent 841eb56 commit 69a407c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/cosim/algorithm/ecco_algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class ecco_algorithm::impl
prev_error_estimate_ = error_estimate;
const auto new_step_size = to_duration(new_step_size_gain * to_double_duration(stepSize, currentTime));
const auto actual_new_step_size = std::clamp(new_step_size, params.min_step_size, params.max_step_size);
// std::cout << "dP=" << sum_power_residual << " dE=" << energy_residual << " eps=" << error_estimate << " ";
// std::cout << to_double_time_point(currentTime) << " "<< max_power_residual << " " << error_estimate << " " << std::endl;
// std::cout << "new step size: " << to_double_duration(actual_new_step_size, {}) << std::endl;
return actual_new_step_size;
}
Expand Down
12 changes: 12 additions & 0 deletions tests/data/ecco/quarter_truck/OspSystemStructure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@
<InitialValue variable="mass">
<Real value="400"/>
</InitialValue>
<InitialValue variable="solverType">
<String value="Euler"/>
</InitialValue>
<InitialValue variable="timeStep">
<Real value="1e-5"/>
</InitialValue>
</InitialValues>
</Simulator>
<Simulator name="wheel" source="Wheel.fmu">
<InitialValues>
<InitialValue variable="mass">
<Real value="40"/>
</InitialValue>
<InitialValue variable="solverType">
<String value="Euler"/>
</InitialValue>
<InitialValue variable="timeStep">
<Real value="1e-5"/>
</InitialValue>
</InitialValues>
</Simulator>
</Simulators>
Expand Down
48 changes: 25 additions & 23 deletions tests/ecco_algorithm_multi_bond_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main()
cosim::log::set_global_output_level(cosim::log::info);

constexpr cosim::time_point startTime = cosim::to_time_point(0.0);;
constexpr cosim::time_point midTime = cosim::to_time_point(15.0);
constexpr cosim::time_point midTime = cosim::to_time_point(4.0);

auto ecco_params = cosim::ecco_parameters{
0.8,
Expand Down Expand Up @@ -91,21 +91,24 @@ int main()
auto file_obs = std::make_unique<cosim::file_observer>("./logDir", logXmlPath);
execution.add_observer(std::move(file_obs));

auto simResult = execution.simulate_until(midTime);
REQUIRE(simResult);
// auto simResult = execution.simulate_until(midTime);
// REQUIRE(simResult);


/**
// Add an observer that watches the last slave
auto t_observer = std::make_shared<cosim::time_series_observer>(50000);
execution.add_observer(t_observer);
t_observer->start_observing(chassisVel);
t_observer->start_observing(wheelCVel);
t_observer->start_observing(wheelGVel);
t_observer->start_observing(groundVel);
// t_observer->start_observing(wheelGVel);
// t_observer->start_observing(groundVel);
t_observer->start_observing(chassisForce);
t_observer->start_observing(wheelCForce);
t_observer->start_observing(wheelGForce);
t_observer->start_observing(groundForce);
// t_observer->start_observing(wheelGForce);
// t_observer->start_observing(groundForce);

auto csv_observer = std::make_shared<cosim::file_observer>(".");
execution.add_observer(csv_observer);

// Run simulation
auto simResult = execution.simulate_until(midTime);
Expand Down Expand Up @@ -136,20 +139,20 @@ int main()
gsl::make_span(wheelCVels),
gsl::make_span(steps),
gsl::make_span(timeValues));
t_observer->get_real_samples(
wheelGVel.simulator,
wheelGVel.reference,
0,
gsl::make_span(wheelGVels),
gsl::make_span(steps),
gsl::make_span(timeValues));
t_observer->get_real_samples(
groundVel.simulator,
groundVel.reference,
0,
gsl::make_span(groundVels),
gsl::make_span(steps),
gsl::make_span(timeValues));
// t_observer->get_real_samples(
// wheelGVel.simulator,
// wheelGVel.reference,
// 0,
// gsl::make_span(wheelGVels),
// gsl::make_span(steps),
// gsl::make_span(timeValues));
// t_observer->get_real_samples(
// groundVel.simulator,
// groundVel.reference,
// 0,
// gsl::make_span(groundVels),
// gsl::make_span(steps),
// gsl::make_span(timeValues));


std::cout << "time,step #,stepsize,chassisVel,wheelCVel,wheelGVel,groundVel" << std::endl;
Expand All @@ -163,7 +166,6 @@ int main()
<< "," << groundVels[i]
<< std::endl;
}
**/
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
return 1;
Expand Down

0 comments on commit 69a407c

Please sign in to comment.