MCPcopy Create free account
hub / github.com/ElectroZybr/LatticeLab / updateSimulationDebug

Function updateSimulationDebug

App/debug/UpdateDebugData.cpp:56–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void updateSimulationDebug(const DebugViews& debugViews, const Lattice::Simulation& simulation, std::string_view integratorName) {
57 struct StepsRateSample {
58 int lastStep = 0;
59 std::chrono::steady_clock::time_point lastTime = std::chrono::steady_clock::now();
60 float rate = 0.0f;
61 };
62
63 static StepsRateSample stepsRateSample{};
64
65 const AtomStorage& atoms = simulation.atoms();
66 const World& world = simulation.world();
67 const NeighborList& neighborList = simulation.neighborList();
68 const Profiler& profiler = Profiler::instance();
69 const double renderMs = lastProfileSampleMs(profiler, {"SceneViewport::renderFrame", "Application::RenderFrame"});
70 const double captureReadbackMs = lastProfileSampleMs(profiler, {"Capture::readback", "FrameProducer::onBufferMapped"});
71 const double captureEncodeMs = lastProfileSampleMs(profiler, {"Capture::encodeFrame", "FFmpegStreamer::writeFrame"});
72 const double physicsMs =
73 std::max({profiler.lastActiveMs("Simulation::update"), profiler.lastActiveMs("Simulation::updateAll"),
74 profiler.lastActiveMs("Simulation::updateWorld")});
75 const int simStep = simulation.world().getSimStep();
76 const auto now = std::chrono::steady_clock::now();
77 const float elapsedSeconds = std::chrono::duration<float>(now - stepsRateSample.lastTime).count();
78 if (elapsedSeconds >= 0.25f) {
79 stepsRateSample.rate = elapsedSeconds > 0.0f ? static_cast<float>(simStep - stepsRateSample.lastStep) / elapsedSeconds : 0.0f;
80 stepsRateSample.lastStep = simStep;
81 stepsRateSample.lastTime = now;
82 }
83 const float stepsPerSecond = stepsRateSample.rate;
84
85 debugViews.sim->add_data("Средняя скорость (км/ч)", simulation.world().getMetrics().averageSpeedKmPerHour());
86 debugViews.sim->add_data("Полная энергия (pj)", simulation.world().getMetrics().fullAverageEnergyEv() * simulation.atoms().size() * Units::kEvToPJ);
87 debugViews.sim->add_data("Полная средняя энергия (eV)", simulation.world().getMetrics().fullAverageEnergyEv());
88 debugViews.sim->add_data("Температура (K)", simulation.world().getMetrics().temperatureK());
89 debugViews.sim->add_data("Температура (°C)", simulation.world().getMetrics().temperatureC());
90 debugViews.sim->add_data("Память (МБ)", MemoryMetrics::getRSS() / 1024.f / 1024.f);
91 debugViews.sim->add_data("Рендер (мс)", renderMs);
92 debugViews.sim->add_data("Capture readback (ms)", captureReadbackMs);
93 debugViews.sim->add_data("Capture encode (ms)", captureEncodeMs);
94 debugViews.sim->add_data("Физика (мс)", physicsMs);
95 debugViews.sim->add_data("Количество атомов", atoms.size());
96 debugViews.sim->add_data("Шаги симуляции", simStep);
97 debugViews.sim->add_data("Шагов/с", stepsPerSecond);
98 debugViews.sim->add_data("Время симуляции (ns)", simulation.simTimeNs());
99 debugViews.sim->add_data("Тип интегратора", integratorName);
100
101 const std::string gridSize =
102 std::format("{} x {} x {}", std::max<long long>(0, world.getGrid().size.x - 2), std::max<long long>(0, world.getGrid().size.y - 2),
103 std::max<long long>(0, world.getGrid().size.z - 2));
104 debugViews.neighbor->add_data("Размер сетки", gridSize);
105 const std::string boxSizeNm = std::format("{:.2f} x {:.2f} x {:.2f}", world.getWorldSize().x * Units::AngstromToNm,
106 world.getWorldSize().y * Units::AngstromToNm, world.getWorldSize().z * Units::AngstromToNm);
107 debugViews.neighbor->add_data("Размер бокса (nm)", boxSizeNm);
108 debugViews.neighbor->add_data("Размер ячейки", world.getGrid().cellSize);
109 debugViews.neighbor->add_data("NeighborList включен", std::string("Да"));
110 debugViews.neighbor->add_data("Память AtomStorage (МБ)", static_cast<float>(atoms.memoryBytes()) / 1024.0f / 1024.0f);
111 debugViews.neighbor->add_data("Память NeighborList (МБ)", static_cast<float>(neighborList.memoryBytes()) / 1024.0f / 1024.0f);
112 debugViews.neighbor->add_data("Память SpatialGrid (МБ)", static_cast<float>(world.getGrid().memoryBytes()) / 1024.0f / 1024.0f);
113 debugViews.neighbor->add_data("Пар в NL", neighborList.pairStorageSize());

Callers 1

Calls 15

lastProfileSampleMsFunction · 0.85
lastActiveMsMethod · 0.80
add_dataMethod · 0.80
simTimeNsMethod · 0.80
pairStorageSizeMethod · 0.80
avgNeighborsPerAtomMethod · 0.80
cutoffMethod · 0.80
skinMethod · 0.80
listRadiusMethod · 0.80
lastRebuildTimeMsMethod · 0.80
lastNonEmptyCellCountMethod · 0.80

Tested by

no test coverage detected