From 6aa03c61172b0381a8f5aead8dd41e0772e96274 Mon Sep 17 00:00:00 2001 From: albertNos Date: Mon, 18 Apr 2022 11:26:08 +0200 Subject: [PATCH 01/11] constellation insertion based on calendar time + few changes --- src/ladds/io/SatelliteLoader.cpp | 21 ++++---- src/ladds/particle/Constellation.cpp | 78 +++++++++++++++++++++++----- src/ladds/particle/Constellation.h | 66 ++++++++++++++++++++--- 3 files changed, 135 insertions(+), 30 deletions(-) diff --git a/src/ladds/io/SatelliteLoader.cpp b/src/ladds/io/SatelliteLoader.cpp index 51f0d259..575f41f1 100644 --- a/src/ladds/io/SatelliteLoader.cpp +++ b/src/ladds/io/SatelliteLoader.cpp @@ -84,20 +84,12 @@ void SatelliteLoader::loadSatellites(AutoPas_t &autopas, ConfigReader &config, c std::vector SatelliteLoader::loadConstellations(ConfigReader &config, const Logger &logger) { std::vector constellations; - auto coefficientOfDrag = config.get("sim/prop/coefficientOfDrag"); auto constellationList = config.get("io/constellationList", "", true); - // altitudeSpread = 3 * sigma , altitudeDeviation = sigma (= standardDeviation) - auto altitudeDeviation = config.get("io/altitudeSpread", 0.0) / 3.0; if (not constellationList.empty()) { const auto insertionFrequency = config.get("io/constellationFrequency", 1); auto constellationDataStr = config.get("io/constellationList"); // count constellation by counting ';' - int nConstellations = 1; - for (char con : constellationDataStr) { - if (con == ';') { - nConstellations++; - } - } + int nConstellations = std::count(constellationDataStr.begin(),constellationDataStr.end(),';') + 1; // parse constellation info constellations.reserve(nConstellations); @@ -110,7 +102,7 @@ std::vector SatelliteLoader::loadConstellations(ConfigReader &con ConfigReader(std::string(DATADIR) + constellationDir + "/shells_" + constellationDir + ".yaml", logger); constellations.emplace_back( - Constellation(constellationConfig, insertionFrequency, altitudeDeviation, coefficientOfDrag)); + Constellation(constellationConfig, config)); if (i != nConstellations - 1) { constellationDataStr.erase(0, offset + 1); } @@ -125,6 +117,15 @@ std::vector SatelliteLoader::loadConstellations(ConfigReader &con "{} more particles will be added from {} constellations", constellationTotalNumSatellites, nConstellations); + + for(auto & c : constellations){ + SPDLOG_LOGGER_INFO(logger.get(), + "{}: insertion starts at iteration: {}, is fully deployed within {} iterations, inserts {} satellites", + c.getConstellationName(), + c.getStartTime(), + c.getDuration(), + c.getConstellationSize()); + } } return constellations; } \ No newline at end of file diff --git a/src/ladds/particle/Constellation.cpp b/src/ladds/particle/Constellation.cpp index b02b6bb1..70fe3ec1 100644 --- a/src/ladds/particle/Constellation.cpp +++ b/src/ladds/particle/Constellation.cpp @@ -14,28 +14,32 @@ std::mt19937 Constellation::generator{42}; -Constellation::Constellation(ConfigReader &constellationConfig, - size_t interval, - double altitudeDeviation, - double coefficientOfDrag) - : interval(interval), altitudeDeviation(altitudeDeviation), distribution(0., altitudeDeviation) { - auto constellationName = constellationConfig.get("constellation/name"); +Constellation::Constellation(ConfigReader &constellationConfig,ConfigReader &config): + constellationName(constellationConfig.get("constellation/name")), + interval(config.get("io/constellationFrequency",1)), + deltaT(config.get("sim/deltaT")), + /* altitudeSpread = 3 * sigma */ + distribution(std::normal_distribution(0,config.get("io/altitudeSpread", 0.0) / 3.0)) +{ + + auto coefficientOfDrag = config.get("sim/prop/coefficientOfDrag"); + + //set constellations insertion start and duration + setStartTime(constellationConfig.get("constellation/startTime"), + config.get("sim/referenceTime","2022/01/01")); + setDuration(constellationConfig.get("constellation/duration")); std::vector sats = readDatasetConstellation(std::string(DATADIR) + constellationName + "/pos_" + constellationName + ".csv", std::string(DATADIR) + constellationName + "/v_" + constellationName + ".csv", coefficientOfDrag); - - // convert vector to deque + // convert vector to deque and add noise to altitude constellationSize = sats.size(); for (size_t i = 0ul; i < constellationSize; ++i) { sats[i].setPosition(randomDisplacement(sats[i].getPosition())); satellites.push_back(sats[i]); } - startTime = constellationConfig.get("constellation/startTime"); - duration = constellationConfig.get("constellation/duration"); - int nShells = constellationConfig.get("constellation/nShells"); for (int i = 1; i <= nShells; i++) { std::string attribute = "shell" + std::to_string(i); @@ -59,6 +63,30 @@ Constellation::Constellation(ConfigReader &constellationConfig, } } +void Constellation::setStartTime(const std::string &startTime_str, const std::string &refTime_str) { + //date string + if(startTime_str.find('/') != std::string::npos) { + std::array dateArrayStart = parseDatestring(startTime_str); + std::array dateArrayRef = parseDatestring(refTime_str); + struct tm stm = {0,0,0,dateArrayStart[2],dateArrayStart[1] - 1,dateArrayStart[0]}; + struct tm t0 = {0,0,0,dateArrayRef[2],dateArrayRef[1] - 1,dateArrayRef[0]}; + + time_t stime = std::mktime(&stm) - std::mktime(&t0); + startTime = static_cast(static_cast(stime) / deltaT); + return; + } + //iteration + startTime = std::stoi(startTime_str); +} + +void Constellation::setDuration(const std::string &duration_str) { + if(duration_str[duration_str.size()-1] == 'd') { + duration = static_cast(24*60*60*std::stoi(duration_str.substr(0,duration_str.size()-1)) / deltaT); + } else { + duration = std::stoi(duration_str); + } +} + std::vector Constellation::tick() { std::vector particles{}; switch (status) { @@ -76,7 +104,7 @@ std::vector Constellation::tick() { while (static_cast(timeActive) >= timestamps[currentShellIndex] + planesDeployed * timeSteps[currentShellIndex]) { - int planeSize = static_cast(shells[currentShellIndex][3]); + auto planeSize = static_cast(shells[currentShellIndex][3]); particles.reserve(planeSize); for (int i = 0; i < planeSize; i++) { particles.push_back(satellites[0]); @@ -107,6 +135,18 @@ size_t Constellation::getConstellationSize() const { return constellationSize; } +std::string Constellation::getConstellationName() const { + return constellationName; +} + +long Constellation::getStartTime() const { + return startTime; +} + +size_t Constellation::getDuration() const { + return duration; +} + std::vector Constellation::readDatasetConstellation(const std::string &position_filepath, const std::string &velocity_filepath, double coefficientOfDrag) { @@ -159,3 +199,17 @@ std::array Constellation::randomDisplacement(const std::array Constellation::parseDatestring(const std::string &date_str) { + std::array dateArray{}; + std::string current_str = date_str; + size_t current_idx = current_str.find('/'); + for(int i = 0;i<3;i++) { + dateArray[i] = std::stoi(current_str.substr(0,current_idx)); + if(i != 2) { + current_str = current_str.erase(0,current_idx + 1); + current_idx = current_str.find('/'); + } + } + return dateArray; +} diff --git a/src/ladds/particle/Constellation.h b/src/ladds/particle/Constellation.h index 10c0bcca..b5e257cd 100644 --- a/src/ladds/particle/Constellation.h +++ b/src/ladds/particle/Constellation.h @@ -33,7 +33,27 @@ class Constellation { * altitudes. Equals the standard deviation of a normal distribution * @param coefficientOfDrag c_D used to initialize all satellites. */ - Constellation(ConfigReader &constellationConfig, size_t interval, double altitudeDeviation, double coefficientOfDrag); + Constellation(ConfigReader &constellationConfig, ConfigReader &config); + + /** + * sets internal attribute startTime according to the passed date string + * startTime_str + * @param startTime a point in time either in iterations or as a date string. if + * the string represents a natural number, it is considered as an iteration + * and the string is converted to a number, if it is a date string it is converted + * to an iteration timestamp before startTime is set to that value + */ + void setStartTime(const std::string &startTime_str, const std::string &refTime_str); + + /** + * sets internal attribute duration according to the passed string parameter + * duration_str + * @param duration_str represents the duration of deployment in either iterations + * or days. the parameter is considered as a count of days when its last character + * equals 'd' and an iteration count otherwise + */ + void setDuration(const std::string &duration_str); + /** * determines which satellites are being added to the simulation by adding each shell * within a time span proportional to the shells size. shells are added plane by plane @@ -48,12 +68,35 @@ class Constellation { */ [[nodiscard]] size_t getConstellationSize() const; + /** + * getter for constellationName = name of this constellation + * @return std::sting : constellationName + */ + [[nodiscard]] std::string getConstellationName() const; + + /** + * getter for startTime = timestamp (iteration) when constellation insertion starts + * @return size_t : timestamp (iteration) when constellation insertion starts + */ + [[nodiscard]] long getStartTime() const; + + /** + * getter for duration = timespan over which constellation insertion takes place + * @return size_t : timespan over which constellation insertion takes place + */ + [[nodiscard]] size_t getDuration() const; + private: /** * stores the satellites of the constellation that have not been added to the simulation */ std::deque satellites{}; + /** + * the name of the constellation + */ + std::string constellationName; + /** * Reads the passed position and velocity csv files. Returns a vector of particles. * @param position_filepath @@ -73,10 +116,17 @@ class Constellation { */ std::array randomDisplacement(const std::array &pos); + /** + * parses datestring with expected format // + * @param datestr datestring + * @return integer array with year, month, and day + */ + static std::array parseDatestring(const std::string &date_str); + /** * iteration from which constellation starts being added to the simulation */ - size_t startTime = 0; + long startTime = 0; /** * time span over which satellites of the constellation are being added @@ -95,6 +145,12 @@ class Constellation { */ size_t interval = 0; + /** + * deltaT of the simulation passed to constellations for converting datestring time + * into simulation time expressed in iterations + */ + double deltaT; + /** * multiples of interval. the constellations state is set to 'a' = active whenever * simulationTime reaches startTime @@ -149,12 +205,6 @@ class Constellation { */ int planesDeployed = 0; - /** - * deviation parameter of the normal distribution that determines the deviation - * of the satellites base altitude. Equals the standard deviation of a normal distribution - */ - double altitudeDeviation; - /** * seeded/deterministic random number generator used to add noise to the * altitudes of satellites From f624b6b6ac57f361745f8ff37019738f518a0b38 Mon Sep 17 00:00:00 2001 From: albertNos Date: Mon, 18 Apr 2022 12:02:45 +0200 Subject: [PATCH 02/11] added constellation data --- data/.gitattributes | 3 +-- data/Amazon/shells_Amazon.yaml | 3 +++ data/AstraPhase1/shells_AstraPhase1.yaml | 3 +++ data/AstraPhase2/shells_AstraPhase2.yaml | 3 +++ data/AstraPhase3/shells_AstraPhase3.yaml | 3 +++ data/GuoWang/shells_GuoWang.yaml | 3 +++ data/OneWebPhase1/pos_OneWebPhase1.csv | 2 +- data/OneWebPhase1/shells_OneWebPhase1.yaml | 3 +++ data/OneWebPhase1/v_OneWebPhase1.csv | 2 +- data/OneWebPhase2/pos_OneWebPhase2.csv | 2 +- data/OneWebPhase2/shells_OneWebPhase2.yaml | 3 +++ data/OneWebPhase2/v_OneWebPhase2.csv | 2 +- data/StarlinkGen1/shells_StarlinkGen1.yaml | 3 +++ data/Telesat/shells_Telesat.yaml | 3 +++ 14 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 data/Amazon/shells_Amazon.yaml create mode 100644 data/AstraPhase1/shells_AstraPhase1.yaml create mode 100644 data/AstraPhase2/shells_AstraPhase2.yaml create mode 100644 data/AstraPhase3/shells_AstraPhase3.yaml create mode 100644 data/GuoWang/shells_GuoWang.yaml create mode 100644 data/OneWebPhase1/shells_OneWebPhase1.yaml create mode 100644 data/OneWebPhase2/shells_OneWebPhase2.yaml create mode 100644 data/StarlinkGen1/shells_StarlinkGen1.yaml create mode 100644 data/Telesat/shells_Telesat.yaml diff --git a/data/.gitattributes b/data/.gitattributes index 74d1bf13..2551e90d 100644 --- a/data/.gitattributes +++ b/data/.gitattributes @@ -1,5 +1,4 @@ initial_population.csv filter=lfs diff=lfs merge=lfs -text */pos_*.csv filter=lfs diff=lfs merge=lfs -text */v_*.csv filter=lfs diff=lfs merge=lfs -text -*/shells_*.txt filter=lfs diff=lfs merge=lfs -text -*/xparams_*.txt filter=lfs diff=lfs merge=lfs -text +*/shells_*.yaml filter=lfs diff=lfs merge=lfs -text diff --git a/data/Amazon/shells_Amazon.yaml b/data/Amazon/shells_Amazon.yaml new file mode 100644 index 00000000..2adb6987 --- /dev/null +++ b/data/Amazon/shells_Amazon.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ddcef4c48813e13ab10976614416c2e75c85d14e202ddd294c881c894b8b3e0 +size 560 diff --git a/data/AstraPhase1/shells_AstraPhase1.yaml b/data/AstraPhase1/shells_AstraPhase1.yaml new file mode 100644 index 00000000..8ea1d832 --- /dev/null +++ b/data/AstraPhase1/shells_AstraPhase1.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9645b07acd19f13389e49edfaeacbe3cbc6b417ba1dd212d1e97487abc72114c +size 243 diff --git a/data/AstraPhase2/shells_AstraPhase2.yaml b/data/AstraPhase2/shells_AstraPhase2.yaml new file mode 100644 index 00000000..35686ad4 --- /dev/null +++ b/data/AstraPhase2/shells_AstraPhase2.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:55e6a1b5e075eb0b1e3809938e064207a05a692e83e0b9d88b24d633ae623889 +size 406 diff --git a/data/AstraPhase3/shells_AstraPhase3.yaml b/data/AstraPhase3/shells_AstraPhase3.yaml new file mode 100644 index 00000000..f6638c6f --- /dev/null +++ b/data/AstraPhase3/shells_AstraPhase3.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd9ac9f22a7988163a0523b9833e06802f628c02172246d4e7149e083233d1c1 +size 566 diff --git a/data/GuoWang/shells_GuoWang.yaml b/data/GuoWang/shells_GuoWang.yaml new file mode 100644 index 00000000..d4730d8e --- /dev/null +++ b/data/GuoWang/shells_GuoWang.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:697bc324e7c44ddfa65ef15ef5bd58f98255999c656b1e972df09887292b75f0 +size 1232 diff --git a/data/OneWebPhase1/pos_OneWebPhase1.csv b/data/OneWebPhase1/pos_OneWebPhase1.csv index 6bd47a8b..5ba7269f 100644 --- a/data/OneWebPhase1/pos_OneWebPhase1.csv +++ b/data/OneWebPhase1/pos_OneWebPhase1.csv @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5cb02cfaec2497b8f6aa753fd72dc11fee6f5d9c115993de88e600c203d78fe9 +oid sha256:103b7ccc38a11f6f47a929214049f8bfcdda1e048e466a8bbb4a3ac52e03167d size 54768 diff --git a/data/OneWebPhase1/shells_OneWebPhase1.yaml b/data/OneWebPhase1/shells_OneWebPhase1.yaml new file mode 100644 index 00000000..97e85422 --- /dev/null +++ b/data/OneWebPhase1/shells_OneWebPhase1.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae5a0f9ff0b595e124a70bc48cefc9f7373846c54d4a5729abdcc3b65a1647f8 +size 409 diff --git a/data/OneWebPhase1/v_OneWebPhase1.csv b/data/OneWebPhase1/v_OneWebPhase1.csv index bf1a54a9..7ec7589f 100644 --- a/data/OneWebPhase1/v_OneWebPhase1.csv +++ b/data/OneWebPhase1/v_OneWebPhase1.csv @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:34a4d25a90f03550514b2bee5f7037e6bfde73c9ef2462c33a2876bd636bdbbe +oid sha256:2602e9683f5580d152dda1774b62519b375170b74bd934fd595c4e321fbedc17 size 54780 diff --git a/data/OneWebPhase2/pos_OneWebPhase2.csv b/data/OneWebPhase2/pos_OneWebPhase2.csv index 80cb1c1d..7005b1b8 100644 --- a/data/OneWebPhase2/pos_OneWebPhase2.csv +++ b/data/OneWebPhase2/pos_OneWebPhase2.csv @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a5c4f1c31d1456fe937d5d5c07b411976f3a7803edfd7db5985b58a98a6da56d +oid sha256:ecb015a543c48085e4956121edfa64950b9d6fb5df5662e02fbb5c2fe522edf6 size 487440 diff --git a/data/OneWebPhase2/shells_OneWebPhase2.yaml b/data/OneWebPhase2/shells_OneWebPhase2.yaml new file mode 100644 index 00000000..c5a06497 --- /dev/null +++ b/data/OneWebPhase2/shells_OneWebPhase2.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:77171a86e19fd348e4e2da017a945a473ebb4d37bc6aa547b5c12695cb9e09ad +size 631 diff --git a/data/OneWebPhase2/v_OneWebPhase2.csv b/data/OneWebPhase2/v_OneWebPhase2.csv index dac0a4b5..72381990 100644 --- a/data/OneWebPhase2/v_OneWebPhase2.csv +++ b/data/OneWebPhase2/v_OneWebPhase2.csv @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a7905f11172dde899b644cb1602089031595eaad3b90cbf1edd78c32e6b14e4f +oid sha256:02e3dc1c5404b6c391ea48c00aeb662eb25903ce1f534534449bfd0fa50ba243 size 487476 diff --git a/data/StarlinkGen1/shells_StarlinkGen1.yaml b/data/StarlinkGen1/shells_StarlinkGen1.yaml new file mode 100644 index 00000000..7afe535b --- /dev/null +++ b/data/StarlinkGen1/shells_StarlinkGen1.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28a6e6922f11960dcda74b84e68614529f2d8728bc6b2323f808f3199f94b0af +size 1393 diff --git a/data/Telesat/shells_Telesat.yaml b/data/Telesat/shells_Telesat.yaml new file mode 100644 index 00000000..9012b20c --- /dev/null +++ b/data/Telesat/shells_Telesat.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e21d43e3b39db3190fcee9f24fc08dede6be3cccfff274e03dad1ae462d3d93e +size 407 From 736cb5f5c95da215d556a0f052dead0b83c3a93b Mon Sep 17 00:00:00 2001 From: albertNos Date: Mon, 18 Apr 2022 15:16:25 +0200 Subject: [PATCH 03/11] id numberspaces for constellations --- src/ladds/particle/Constellation.cpp | 7 ++++++- src/ladds/particle/Constellation.h | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ladds/particle/Constellation.cpp b/src/ladds/particle/Constellation.cpp index 70fe3ec1..e673e89e 100644 --- a/src/ladds/particle/Constellation.cpp +++ b/src/ladds/particle/Constellation.cpp @@ -12,6 +12,8 @@ #include #include +size_t Constellation::idBase = 1000000; + std::mt19937 Constellation::generator{42}; Constellation::Constellation(ConfigReader &constellationConfig,ConfigReader &config): @@ -61,6 +63,8 @@ Constellation::Constellation(ConfigReader &constellationConfig,ConfigReader &con for (size_t i = 0ul; i < timestamps.size() - 1; ++i) { timeSteps.push_back((timestamps[i + 1] - timestamps[i]) / shells[i][2]); // = duration_i / nPlanes_i } + + idBase += 1000000; } void Constellation::setStartTime(const std::string &startTime_str, const std::string &refTime_str) { @@ -150,6 +154,8 @@ size_t Constellation::getDuration() const { std::vector Constellation::readDatasetConstellation(const std::string &position_filepath, const std::string &velocity_filepath, double coefficientOfDrag) { + size_t particleId = idBase; + CSVReader pos_csvReader{position_filepath, false}; CSVReader vel_csvReader{velocity_filepath, false}; std::vector particleCollection; @@ -164,7 +170,6 @@ std::vector Constellation::readDatasetConstellation(const std::string particleCollection.reserve(positions.size()); - size_t particleId = 0; std::transform(positions.begin(), positions.end(), velocities.begin(), diff --git a/src/ladds/particle/Constellation.h b/src/ladds/particle/Constellation.h index b5e257cd..afc86a71 100644 --- a/src/ladds/particle/Constellation.h +++ b/src/ladds/particle/Constellation.h @@ -216,4 +216,9 @@ class Constellation { * altitude. uses altitudeDeviation as parameter */ std::normal_distribution distribution; + + /** + * variable used to give every satellite that is part of a constellation an id + */ + static size_t idBase; }; From 9820b6aa6565c55fcf660ff2ea348fc5fd2ef765 Mon Sep 17 00:00:00 2001 From: albertNos Date: Tue, 19 Apr 2022 09:24:47 +0200 Subject: [PATCH 04/11] schedule now precomputed and constellations with launch before iteration 0 --- src/ladds/particle/Constellation.cpp | 29 ++++++++++++++++++++-------- src/ladds/particle/Constellation.h | 11 +++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/ladds/particle/Constellation.cpp b/src/ladds/particle/Constellation.cpp index e673e89e..065c8e04 100644 --- a/src/ladds/particle/Constellation.cpp +++ b/src/ladds/particle/Constellation.cpp @@ -53,15 +53,26 @@ Constellation::Constellation(ConfigReader &constellationConfig,ConfigReader &con // determine times when each shell has its deployment started double timestamp = 0; + std::vector timestamps; + timestamps.reserve(nShells+1); timestamps.push_back(0); + for (auto [alt, i, planes, nSats] : shells) { timestamp += (planes * nSats / static_cast(constellationSize)) * static_cast(duration); timestamps.push_back(timestamp); } - - // for each shell determine the interval a new plane is added, each shell has its own timestep - for (size_t i = 0ul; i < timestamps.size() - 1; ++i) { - timeSteps.push_back((timestamps[i + 1] - timestamps[i]) / shells[i][2]); // = duration_i / nPlanes_i + std::cout << "schedule for " << constellationName << ":" << std::endl; + schedule.resize(nShells); + for(int i = 0ul; i < timestamps.size() - 1;++i){ + int nPlanes = static_cast(shells[i][2]); + double timeStepSize = (timestamps[i + 1] - timestamps[i]) / nPlanes; + + schedule[i].reserve(nPlanes); + for(int j = 0ul;j < nPlanes;j++){ + schedule[i].push_back(timestamps[i]+j*timeStepSize); + std::cout << timestamps[i]+j*timeStepSize << " "; + } + std::cout << std::endl; } idBase += 1000000; @@ -99,17 +110,19 @@ std::vector Constellation::tick() { break; case Status::inactive: // check time and activate if startTime is reached - if (simulationTime >= startTime) { + if (static_cast(simulationTime) >= startTime) { status = Status::active; + timeActive = simulationTime - startTime; + std::cout << "timeActive for " << constellationName << ": " << timeActive << std::endl; } else { break; } case Status::active: - while (static_cast(timeActive) >= - timestamps[currentShellIndex] + planesDeployed * timeSteps[currentShellIndex]) { + while (static_cast(timeActive) >= schedule[currentShellIndex][planesDeployed]) { + std::cout << "insertion " << constellationName << ": " << timeActive << std::endl; auto planeSize = static_cast(shells[currentShellIndex][3]); - particles.reserve(planeSize); + particles.reserve(particles.capacity()+planeSize); for (int i = 0; i < planeSize; i++) { particles.push_back(satellites[0]); satellites.pop_front(); diff --git a/src/ladds/particle/Constellation.h b/src/ladds/particle/Constellation.h index afc86a71..5867bd7f 100644 --- a/src/ladds/particle/Constellation.h +++ b/src/ladds/particle/Constellation.h @@ -185,15 +185,10 @@ class Constellation { std::vector> shells{}; /** - * contains the time shell i begins its deployment at vector index i + * a vector containing each shells' schedule. if the entry at currentShellIndex and + * planesDeployed is smaller than timeActive the corresponding plane is added */ - std::vector timestamps{}; - - /** - * contains the time steps of shell i to enable adding each plane of - * shell i linearly over time at vector index i - */ - std::vector timeSteps{}; + std::vector> schedule{}; /** * keeps track of which shell will be added next From 5c3e5777e42ab293b0de410114be87ae78ea707f Mon Sep 17 00:00:00 2001 From: albertNos Date: Tue, 19 Apr 2022 09:36:36 +0200 Subject: [PATCH 05/11] config attribute referenceTime --- cfg/default_cfg.yaml | 1 + data/StarlinkGen2/pos_StarlinkGen2.csv | 3 --- data/StarlinkGen2/v_StarlinkGen2.csv | 3 --- 3 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 data/StarlinkGen2/pos_StarlinkGen2.csv delete mode 100644 data/StarlinkGen2/v_StarlinkGen2.csv diff --git a/cfg/default_cfg.yaml b/cfg/default_cfg.yaml index b46df249..1ddadf96 100644 --- a/cfg/default_cfg.yaml +++ b/cfg/default_cfg.yaml @@ -6,6 +6,7 @@ sim: minutes: 0. # as floating points hours: 0. # as floating points days: 0. # as floating points + referenceTime: 2022/01/01 # calendar day associated with simulation start at iteration 0 (yyyy/mm/dd) maxAltitude: 10000 # Maximum satellite altitude above earth core. This number times two is the simulation box length. [km] minAltitude: 150 # Everything below this altitude above ground will be considered burning up [km] deltaT: 10.0 # [s] diff --git a/data/StarlinkGen2/pos_StarlinkGen2.csv b/data/StarlinkGen2/pos_StarlinkGen2.csv deleted file mode 100644 index 8417b526..00000000 --- a/data/StarlinkGen2/pos_StarlinkGen2.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:84c35d0f42f67fcaaf298687765e838dbf5bc8de11e76793ca48cf952812c4b0 -size 2294998 diff --git a/data/StarlinkGen2/v_StarlinkGen2.csv b/data/StarlinkGen2/v_StarlinkGen2.csv deleted file mode 100644 index 5ab560ef..00000000 --- a/data/StarlinkGen2/v_StarlinkGen2.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9543056ae8b3794b1235caa8f669ecb42d0f847217ba0725bf0fe965585b5cf2 -size 2295002 From 3c9afc6569ca135cf3bd00d38f016d232c5a351e Mon Sep 17 00:00:00 2001 From: albertNos Date: Tue, 19 Apr 2022 10:12:17 +0200 Subject: [PATCH 06/11] clangformat --- src/ladds/io/SatelliteLoader.cpp | 20 +++---- src/ladds/particle/Constellation.cpp | 84 ++++++++++++++-------------- src/ladds/particle/Constellation.h | 38 ++++++------- 3 files changed, 70 insertions(+), 72 deletions(-) diff --git a/src/ladds/io/SatelliteLoader.cpp b/src/ladds/io/SatelliteLoader.cpp index 575f41f1..8081d63f 100644 --- a/src/ladds/io/SatelliteLoader.cpp +++ b/src/ladds/io/SatelliteLoader.cpp @@ -89,7 +89,7 @@ std::vector SatelliteLoader::loadConstellations(ConfigReader &con const auto insertionFrequency = config.get("io/constellationFrequency", 1); auto constellationDataStr = config.get("io/constellationList"); // count constellation by counting ';' - int nConstellations = std::count(constellationDataStr.begin(),constellationDataStr.end(),';') + 1; + int nConstellations = std::count(constellationDataStr.begin(), constellationDataStr.end(), ';') + 1; // parse constellation info constellations.reserve(nConstellations); @@ -101,8 +101,7 @@ std::vector SatelliteLoader::loadConstellations(ConfigReader &con ConfigReader constellationConfig = ConfigReader(std::string(DATADIR) + constellationDir + "/shells_" + constellationDir + ".yaml", logger); - constellations.emplace_back( - Constellation(constellationConfig, config)); + constellations.emplace_back(Constellation(constellationConfig, config)); if (i != nConstellations - 1) { constellationDataStr.erase(0, offset + 1); } @@ -118,13 +117,14 @@ std::vector SatelliteLoader::loadConstellations(ConfigReader &con constellationTotalNumSatellites, nConstellations); - for(auto & c : constellations){ - SPDLOG_LOGGER_INFO(logger.get(), - "{}: insertion starts at iteration: {}, is fully deployed within {} iterations, inserts {} satellites", - c.getConstellationName(), - c.getStartTime(), - c.getDuration(), - c.getConstellationSize()); + for (auto &c : constellations) { + SPDLOG_LOGGER_INFO( + logger.get(), + "{}: insertion starts at iteration: {}, is fully deployed within {} iterations, inserts {} satellites", + c.getConstellationName(), + c.getStartTime(), + c.getDuration(), + c.getConstellationSize()); } } return constellations; diff --git a/src/ladds/particle/Constellation.cpp b/src/ladds/particle/Constellation.cpp index 065c8e04..5493b07a 100644 --- a/src/ladds/particle/Constellation.cpp +++ b/src/ladds/particle/Constellation.cpp @@ -16,19 +16,17 @@ size_t Constellation::idBase = 1000000; std::mt19937 Constellation::generator{42}; -Constellation::Constellation(ConfigReader &constellationConfig,ConfigReader &config): - constellationName(constellationConfig.get("constellation/name")), - interval(config.get("io/constellationFrequency",1)), +Constellation::Constellation(ConfigReader &constellationConfig, ConfigReader &config) + : constellationName(constellationConfig.get("constellation/name")), + interval(config.get("io/constellationFrequency", 1)), deltaT(config.get("sim/deltaT")), /* altitudeSpread = 3 * sigma */ - distribution(std::normal_distribution(0,config.get("io/altitudeSpread", 0.0) / 3.0)) -{ - + distribution(std::normal_distribution(0, config.get("io/altitudeSpread", 0.0) / 3.0)) { auto coefficientOfDrag = config.get("sim/prop/coefficientOfDrag"); - //set constellations insertion start and duration + // set constellations insertion start and duration setStartTime(constellationConfig.get("constellation/startTime"), - config.get("sim/referenceTime","2022/01/01")); + config.get("sim/referenceTime", "2022/01/01")); setDuration(constellationConfig.get("constellation/duration")); std::vector sats = @@ -54,7 +52,7 @@ Constellation::Constellation(ConfigReader &constellationConfig,ConfigReader &con // determine times when each shell has its deployment started double timestamp = 0; std::vector timestamps; - timestamps.reserve(nShells+1); + timestamps.reserve(nShells + 1); timestamps.push_back(0); for (auto [alt, i, planes, nSats] : shells) { @@ -63,14 +61,14 @@ Constellation::Constellation(ConfigReader &constellationConfig,ConfigReader &con } std::cout << "schedule for " << constellationName << ":" << std::endl; schedule.resize(nShells); - for(int i = 0ul; i < timestamps.size() - 1;++i){ + for (int i = 0ul; i < timestamps.size() - 1; ++i) { int nPlanes = static_cast(shells[i][2]); double timeStepSize = (timestamps[i + 1] - timestamps[i]) / nPlanes; schedule[i].reserve(nPlanes); - for(int j = 0ul;j < nPlanes;j++){ - schedule[i].push_back(timestamps[i]+j*timeStepSize); - std::cout << timestamps[i]+j*timeStepSize << " "; + for (int j = 0ul; j < nPlanes; j++) { + schedule[i].push_back(timestamps[i] + j * timeStepSize); + std::cout << timestamps[i] + j * timeStepSize << " "; } std::cout << std::endl; } @@ -79,27 +77,27 @@ Constellation::Constellation(ConfigReader &constellationConfig,ConfigReader &con } void Constellation::setStartTime(const std::string &startTime_str, const std::string &refTime_str) { - //date string - if(startTime_str.find('/') != std::string::npos) { - std::array dateArrayStart = parseDatestring(startTime_str); - std::array dateArrayRef = parseDatestring(refTime_str); - struct tm stm = {0,0,0,dateArrayStart[2],dateArrayStart[1] - 1,dateArrayStart[0]}; - struct tm t0 = {0,0,0,dateArrayRef[2],dateArrayRef[1] - 1,dateArrayRef[0]}; - - time_t stime = std::mktime(&stm) - std::mktime(&t0); - startTime = static_cast(static_cast(stime) / deltaT); - return; - } - //iteration - startTime = std::stoi(startTime_str); + // date string + if (startTime_str.find('/') != std::string::npos) { + std::array dateArrayStart = parseDatestring(startTime_str); + std::array dateArrayRef = parseDatestring(refTime_str); + struct tm stm = {0, 0, 0, dateArrayStart[2], dateArrayStart[1] - 1, dateArrayStart[0]}; + struct tm t0 = {0, 0, 0, dateArrayRef[2], dateArrayRef[1] - 1, dateArrayRef[0]}; + + time_t stime = std::mktime(&stm) - std::mktime(&t0); + startTime = static_cast(static_cast(stime) / deltaT); + return; + } + // iteration + startTime = std::stoi(startTime_str); } void Constellation::setDuration(const std::string &duration_str) { - if(duration_str[duration_str.size()-1] == 'd') { - duration = static_cast(24*60*60*std::stoi(duration_str.substr(0,duration_str.size()-1)) / deltaT); - } else { - duration = std::stoi(duration_str); - } + if (duration_str[duration_str.size() - 1] == 'd') { + duration = static_cast(24 * 60 * 60 * std::stoi(duration_str.substr(0, duration_str.size() - 1)) / deltaT); + } else { + duration = std::stoi(duration_str); + } } std::vector Constellation::tick() { @@ -122,7 +120,7 @@ std::vector Constellation::tick() { while (static_cast(timeActive) >= schedule[currentShellIndex][planesDeployed]) { std::cout << "insertion " << constellationName << ": " << timeActive << std::endl; auto planeSize = static_cast(shells[currentShellIndex][3]); - particles.reserve(particles.capacity()+planeSize); + particles.reserve(particles.capacity() + planeSize); for (int i = 0; i < planeSize; i++) { particles.push_back(satellites[0]); satellites.pop_front(); @@ -218,16 +216,16 @@ std::array Constellation::randomDisplacement(const std::array Constellation::parseDatestring(const std::string &date_str) { - std::array dateArray{}; - std::string current_str = date_str; - size_t current_idx = current_str.find('/'); - for(int i = 0;i<3;i++) { - dateArray[i] = std::stoi(current_str.substr(0,current_idx)); - if(i != 2) { - current_str = current_str.erase(0,current_idx + 1); - current_idx = current_str.find('/'); - } +std::array Constellation::parseDatestring(const std::string &date_str) { + std::array dateArray{}; + std::string current_str = date_str; + size_t current_idx = current_str.find('/'); + for (int i = 0; i < 3; i++) { + dateArray[i] = std::stoi(current_str.substr(0, current_idx)); + if (i != 2) { + current_str = current_str.erase(0, current_idx + 1); + current_idx = current_str.find('/'); } - return dateArray; + } + return dateArray; } diff --git a/src/ladds/particle/Constellation.h b/src/ladds/particle/Constellation.h index 5867bd7f..4ce815b2 100644 --- a/src/ladds/particle/Constellation.h +++ b/src/ladds/particle/Constellation.h @@ -35,24 +35,24 @@ class Constellation { */ Constellation(ConfigReader &constellationConfig, ConfigReader &config); - /** - * sets internal attribute startTime according to the passed date string - * startTime_str - * @param startTime a point in time either in iterations or as a date string. if - * the string represents a natural number, it is considered as an iteration - * and the string is converted to a number, if it is a date string it is converted - * to an iteration timestamp before startTime is set to that value - */ - void setStartTime(const std::string &startTime_str, const std::string &refTime_str); - - /** - * sets internal attribute duration according to the passed string parameter - * duration_str - * @param duration_str represents the duration of deployment in either iterations - * or days. the parameter is considered as a count of days when its last character - * equals 'd' and an iteration count otherwise - */ - void setDuration(const std::string &duration_str); + /** + * sets internal attribute startTime according to the passed date string + * startTime_str + * @param startTime a point in time either in iterations or as a date string. if + * the string represents a natural number, it is considered as an iteration + * and the string is converted to a number, if it is a date string it is converted + * to an iteration timestamp before startTime is set to that value + */ + void setStartTime(const std::string &startTime_str, const std::string &refTime_str); + + /** + * sets internal attribute duration according to the passed string parameter + * duration_str + * @param duration_str represents the duration of deployment in either iterations + * or days. the parameter is considered as a count of days when its last character + * equals 'd' and an iteration count otherwise + */ + void setDuration(const std::string &duration_str); /** * determines which satellites are being added to the simulation by adding each shell @@ -121,7 +121,7 @@ class Constellation { * @param datestr datestring * @return integer array with year, month, and day */ - static std::array parseDatestring(const std::string &date_str); + static std::array parseDatestring(const std::string &date_str); /** * iteration from which constellation starts being added to the simulation From 15f3eaec4a79993eec71a4aa48c92f241d79429e Mon Sep 17 00:00:00 2001 From: albertNos Date: Sat, 23 Apr 2022 14:47:58 +0200 Subject: [PATCH 07/11] several change requests --- README.md | 49 +++--- cfg/default_cfg.yaml | 4 +- data/Amazon/shells_Amazon.yaml | 2 +- data/AstraPhase1/shells_AstraPhase1.yaml | 2 +- data/AstraPhase2/shells_AstraPhase2.yaml | 2 +- data/AstraPhase3/shells_AstraPhase3.yaml | 2 +- data/GuoWang/shells_GuoWang.yaml | 2 +- data/OneWebPhase1/shells_OneWebPhase1.yaml | 2 +- data/OneWebPhase2/shells_OneWebPhase2.yaml | 2 +- data/StarlinkGen1/shells_StarlinkGen1.yaml | 2 +- data/Telesat/shells_Telesat.yaml | 2 +- .../ConstellationGeneration.ipynb | 95 ++++++------ src/ladds/io/SatelliteLoader.cpp | 2 +- src/ladds/particle/Constellation.cpp | 50 +++---- src/ladds/particle/Constellation.h | 141 +++++++++--------- 15 files changed, 170 insertions(+), 189 deletions(-) diff --git a/README.md b/README.md index 1961b484..dd88f852 100644 --- a/README.md +++ b/README.md @@ -109,40 +109,27 @@ Data on current satellites etc. is often found [online](https://www.space-track. ## Generating and including Constellations Satellite constellations (e.g. Starlink, OneWeb) are usually described by a list of orbital shells. An orbital shell is described by a 4-tuple with information about `altitude`, `inclination`, `number of -planes`, and `number of satellites` per plane. We provide a notebook -`notebooks/ConstellationGeneration/ConstellationGeneration.ipynb` that can be used -to generate constellation data from orbital shell parameters. +planes`, and `number of satellites` per plane. We provide a notebook +[`notebooks/ConstellationGeneration/ConstellationGeneration.ipynb`](notebooks/ConstellationGeneration/ConstellationGeneration.ipynb) that can be used -### Generating a constellation (quick guide): -* Initialize the constellation by executing the first cell and providing metadata in the second cell (1) -* Create a shell by providing the 4 shell arguments, and further parameters (extra params) if necessary (2.1). -Store the temporary shell data by executing the cell (2.2) -* Turn satellites into position and velocity vectors by executing cell (3) -* Write the files by executing cell (4) and save them by executing cell (5) +### How constellation satellites are inserted into the simulation -A more detailed guide is included in the notebook. - -### Including the constellation data in simulation (`io` section): - -* In the configuration file for the simulation, include the constellation(s) by -defining `constellationList` and assigning the constellation name(s); Syntax: -{name;}name ; e.g. Astra;Starlink;OneWeb -* `constellationFrequency` (=interval for constellation insertion) -* `constellationCutoff` (satellites are inserted with a delay, if there is an object within this range) -* `altitudeSpread` ([km] ~99.74% of satellites with normally distributed altitude deviate -by less than this value from the mean altitude [altitudeSpread = 3*sigma]) - -### How constellation satellites are inserted to the simulation - -The insertion of a constellation takes as long as specified by the `duration` -parameter in the respective .yaml file. The time it takes to insert one shell of -a constellation depends on the percentage of satellites the shell contributes to -the constellation. Satellites of each orbital shell are inserted plane by plane +The insertion of a constellation takes as long as specified by the `duration` +parameter in the respective .yaml file. The time it takes to insert one shell of +a constellation depends on the percentage of satellites the shell contributes to +the constellation. Satellites of each orbital shell are inserted plane by plane and linearly over time. +### Including the constellation data in simulation (`io` section): - - +In the configuration file for the simulation, include the constellation(s) by +defining the following fields: +* `constellationList`: Semicolon (`;`) separated list of constellation names. E.g. `Astra;Starlink;OneWeb` +* `constellationFrequency`: Number of timesteps between constellation insertions. +* `constellationCutoff`: Satellites are inserted with a delay, if there is an object within this range. +* `altitudeSpread`: `[km]` Three times the standard deviation of the normal distribution describing + the imprecision of orbital insertion. ~99.74% of satellites deviate by less than this value from the + mean altitude. ## Output @@ -177,6 +164,4 @@ Due to burn ups or breakups the number of particles in any iteration might diffe To keep file size reasonable compression is supported. ### CSV -If HDF5 output is disabled entirely, collision data is written in a `.csv` file in ASCII layout. - - +If HDF5 output is disabled entirely, collision data is written in a `.csv` file in ASCII layout. \ No newline at end of file diff --git a/cfg/default_cfg.yaml b/cfg/default_cfg.yaml index 1ddadf96..48e521d0 100644 --- a/cfg/default_cfg.yaml +++ b/cfg/default_cfg.yaml @@ -6,7 +6,7 @@ sim: minutes: 0. # as floating points hours: 0. # as floating points days: 0. # as floating points - referenceTime: 2022/01/01 # calendar day associated with simulation start at iteration 0 (yyyy/mm/dd) + referenceTime: 2022-01-01 # calendar day associated with simulation start at iteration 0 (yyyy/mm/dd) maxAltitude: 10000 # Maximum satellite altitude above earth core. This number times two is the simulation box length. [km] minAltitude: 150 # Everything below this altitude above ground will be considered burning up [km] deltaT: 10.0 # [s] @@ -44,7 +44,7 @@ io: writeFrequency: 1000 # Frequency of writing to the hdf5 file [iterations] compressionLevel: 4 # Valid Levels: 0 (no compression) - 9 (max compression) - #constellationList: AstraPhase2 # ';'-seperated constellations consisting of path (to constellation directory), start time, duration + #constellationList: AstraPhase2 # ';'-seperated constellations consisting of path (to constellation directory) constellationFrequency: 10 # Frequency of adding satellites to simulation [iterations] constellationCutoff: 0.1 # satellites of constellations are only inserted when there is no object within constellationCutoff range altitudeSpread: 1.0 # [km] normal distributed altitude deviations are usually smaller than this value (~99.74% chance) diff --git a/data/Amazon/shells_Amazon.yaml b/data/Amazon/shells_Amazon.yaml index 2adb6987..20cdc367 100644 --- a/data/Amazon/shells_Amazon.yaml +++ b/data/Amazon/shells_Amazon.yaml @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3ddcef4c48813e13ab10976614416c2e75c85d14e202ddd294c881c894b8b3e0 +oid sha256:70c61a31667ee2095fd2d3c42dd9e2e13686f7d5061d3d6c9c883a829dae823c size 560 diff --git a/data/AstraPhase1/shells_AstraPhase1.yaml b/data/AstraPhase1/shells_AstraPhase1.yaml index 8ea1d832..9b7cefa8 100644 --- a/data/AstraPhase1/shells_AstraPhase1.yaml +++ b/data/AstraPhase1/shells_AstraPhase1.yaml @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9645b07acd19f13389e49edfaeacbe3cbc6b417ba1dd212d1e97487abc72114c +oid sha256:1b1dc8833e67c13b0f5d7a0ea99f75a17d7fec9c1a5d2502073e985d1028f7f1 size 243 diff --git a/data/AstraPhase2/shells_AstraPhase2.yaml b/data/AstraPhase2/shells_AstraPhase2.yaml index 35686ad4..170ec022 100644 --- a/data/AstraPhase2/shells_AstraPhase2.yaml +++ b/data/AstraPhase2/shells_AstraPhase2.yaml @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:55e6a1b5e075eb0b1e3809938e064207a05a692e83e0b9d88b24d633ae623889 +oid sha256:a5c5ab5ffe878c9c941904c0579e43c058707ede777bed5e21a14ef6bcc92b25 size 406 diff --git a/data/AstraPhase3/shells_AstraPhase3.yaml b/data/AstraPhase3/shells_AstraPhase3.yaml index f6638c6f..1725cda3 100644 --- a/data/AstraPhase3/shells_AstraPhase3.yaml +++ b/data/AstraPhase3/shells_AstraPhase3.yaml @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dd9ac9f22a7988163a0523b9833e06802f628c02172246d4e7149e083233d1c1 +oid sha256:16c04e00fa890da313a5956f9db38be0959d29d06a47c48052db3b50856ea1e8 size 566 diff --git a/data/GuoWang/shells_GuoWang.yaml b/data/GuoWang/shells_GuoWang.yaml index d4730d8e..29f8068c 100644 --- a/data/GuoWang/shells_GuoWang.yaml +++ b/data/GuoWang/shells_GuoWang.yaml @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:697bc324e7c44ddfa65ef15ef5bd58f98255999c656b1e972df09887292b75f0 +oid sha256:c4ca8bbf57c56c0c97deff7d92788dc300dc8f61c06ef33eea7ff3dc7df5e98c size 1232 diff --git a/data/OneWebPhase1/shells_OneWebPhase1.yaml b/data/OneWebPhase1/shells_OneWebPhase1.yaml index 97e85422..7defec10 100644 --- a/data/OneWebPhase1/shells_OneWebPhase1.yaml +++ b/data/OneWebPhase1/shells_OneWebPhase1.yaml @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae5a0f9ff0b595e124a70bc48cefc9f7373846c54d4a5729abdcc3b65a1647f8 +oid sha256:0530589328780984510dbf84ea98478ae1d6a421322b5a2ecaaa8695d0906200 size 409 diff --git a/data/OneWebPhase2/shells_OneWebPhase2.yaml b/data/OneWebPhase2/shells_OneWebPhase2.yaml index c5a06497..605d271b 100644 --- a/data/OneWebPhase2/shells_OneWebPhase2.yaml +++ b/data/OneWebPhase2/shells_OneWebPhase2.yaml @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:77171a86e19fd348e4e2da017a945a473ebb4d37bc6aa547b5c12695cb9e09ad +oid sha256:fdaf6d8c9afa352f621ecd892e59daaa89f4a4faeb26ec30fbffc9aff490bf02 size 631 diff --git a/data/StarlinkGen1/shells_StarlinkGen1.yaml b/data/StarlinkGen1/shells_StarlinkGen1.yaml index 7afe535b..c20dd5c1 100644 --- a/data/StarlinkGen1/shells_StarlinkGen1.yaml +++ b/data/StarlinkGen1/shells_StarlinkGen1.yaml @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:28a6e6922f11960dcda74b84e68614529f2d8728bc6b2323f808f3199f94b0af +oid sha256:7ac5af2695c4a2860ad24be903f77d248d48d7605b858885b7f9b16c0bbbd2f5 size 1393 diff --git a/data/Telesat/shells_Telesat.yaml b/data/Telesat/shells_Telesat.yaml index 9012b20c..47d614d7 100644 --- a/data/Telesat/shells_Telesat.yaml +++ b/data/Telesat/shells_Telesat.yaml @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e21d43e3b39db3190fcee9f24fc08dede6be3cccfff274e03dad1ae462d3d93e +oid sha256:0eebe16cb8f8c87384c277d0b3e79fee01494a904c5efdac560fa0b7e243f15d size 407 diff --git a/notebooks/ConstellationGeneration/ConstellationGeneration.ipynb b/notebooks/ConstellationGeneration/ConstellationGeneration.ipynb index 6a84ff83..60f11b27 100644 --- a/notebooks/ConstellationGeneration/ConstellationGeneration.ipynb +++ b/notebooks/ConstellationGeneration/ConstellationGeneration.ipynb @@ -13,6 +13,15 @@ "id": "6ef7e733", "metadata": {}, "source": [ + "## Quick guide:\n", + "* Initialize the constellation by executing the first cell and providing metadata in the second cell (1)\n", + "* Create a shell by providing the 4 shell arguments, and further parameters (extra params) if necessary (2.1).\n", + "Store the temporary shell data by executing the cell (2.2)\n", + "* Turn satellites into position and velocity vectors by executing cell (3)\n", + "* Write the files by executing cell (4) and save them by executing cell (5)\n", + "\n", + "The following guide contains more detail\n", + "\n", "## Detailed guide:\n", "\n", "### 0. Execute the first cell to import libraries and initialize variables\n", @@ -20,7 +29,7 @@ "### 1. Initialize Constellation and reset planet_list and other lists\n", "Provide the constellation name, the time of launch `startTime` as well as\n", "the time it takes to fully deploy the constellation `duration` and execute the cell. \n", - "`startTime` can be specified as a date string with the format \"YYYY/MM/DD\". `duration` is specified as a string that contains a number of days followed by the 'd' character. If the variables are assigned plain integers, the values will be interpreted as simulation iterations.\n", + "`startTime` can be specified as a date string with the format \"YYYY-MM-DD\". `duration` is specified as a string that contains a number of days followed by the 'd' character. If the variables are assigned plain integers, the values will be interpreted as simulation iterations.\n", "### 2.1 Generate shell = ( altitude, inclination, nPlanes, nSats )\n", "The execution of this cell creates one temporary shell (each satellite is described by orbital elements) that is not yet a part of the constellation. It is possible to visualize the generated satellites by executing the cell `Plot current shell` before adding it to the constellation. Append the shell to the constellation by executing cell `2.2`. Each time the code of `2.1` is run, the temporary data is overridden by the new data.\n", "\n", @@ -34,7 +43,7 @@ "\n", "In some cases it is necessary to specify more parameters: `offsetM`, `argPeriapsis`,\n", "`startingW`, and `W_area`. It is best to modify them only if necessary and to use\n", - "the default values otherwise. Refer to the end of the description to see their usage\n", + "the default values otherwise. Refer to the end of the notebook to see their usage\n", "information (additional parameters).\n", "\n", "### 2.2 Append to elements_list and other\n", @@ -53,44 +62,7 @@ "Create a directory with the same name that was specified in `1` in the variable\n", "`constellation_name` in the `data` directory of the project. It contains three\n", "files: Two .csv files with positions and velocities and a .yaml file with the\n", - "metadata of the constellation.\n", - "\n", - "---\n", - "\n", - "### Additional parameters\n", - "### offsetM\n", - "`offsetM` is the step size for an offset that is added to each satellite's mean anomaly. The offset accumulates, meaning it increases by `offsetM` each time a new plane is generated. In a Walker Constellation, \n", - "which is a typical model for constellations, the parameter is assigned a value of the following form:\n", - "\n", - "`offsetM = F * 360 / (nPlanes*nSats)` \n", - "\n", - "Note: F is a natural number: F is element of {0, ... , nPlanes - 1}\n", - "\n", - "Note: the property of a set phasing difference\n", - "between neighboring planes gets lost if the shell is added over time (`duration` > 0)\n", - "\n", - "\n", - "\n", - "### argPeriapsis\n", - "`argPeriapsis` corresponds to the orbital element \"argument of periapsis\". Choosing an irrational number\n", - "prevents satellites from two symmetrical planes to have the same position.\n", - "\n", - "### startingW\n", - "`startingW` is the base value for the shell's longitude of ascending node (W). The parameter can be utilized if planes of different shells overlap. This occurs if shells have the same altitude and the same or similar inclination.\n", - "\n", - "The shells should follow the formula:\n", - "\n", - "`(360/G)*(i/N)`\n", - "\n", - "Note: G stands for the smallest common denominator of the nPlanes parameters of\n", - "each shell\n", - "\n", - "Note: N is the number of shells overlapping\n", - "\n", - "Note: i is an index in {0,...,N-1}. each shell should have a distinct i\n", - "\n", - "### W_area\n", - "this parameter determines which degree the planes of the shell span. The longitudes of ascending node are distributed in the range \\[startingW , startingW + W_area\\]." + "metadata of the constellation." ] }, { @@ -382,12 +354,45 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "id": "c2328ea2", + "cell_type": "markdown", + "id": "19cfec21", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "### Additional parameters\n", + "### offsetM\n", + "`offsetM` is the step size for an offset that is added to each satellite's mean anomaly. The offset accumulates, meaning it increases by `offsetM` each time a new plane is generated. In a Walker Constellation, \n", + "which is a typical model for constellations, the parameter is assigned a value of the following form:\n", + "\n", + "`offsetM = F * 360 / (nPlanes*nSats)` \n", + "\n", + "Note: F is a natural number: F is element of {0, ... , nPlanes - 1}\n", + "\n", + "Note: the property of a set phasing difference\n", + "between neighboring planes gets lost if the shell is added over time (`duration` > 0)\n", + "\n", + "\n", + "\n", + "### argPeriapsis\n", + "`argPeriapsis` corresponds to the orbital element \"argument of periapsis\". Choosing an irrational number\n", + "prevents satellites from two symmetrical planes to have the same position.\n", + "\n", + "### startingW\n", + "`startingW` is the base value for the shell's longitude of ascending node (W). The parameter can be utilized if planes of different shells overlap. This occurs if shells have the same altitude and the same or similar inclination.\n", + "\n", + "The shells should follow the formula:\n", + "\n", + "`(360/G)*(i/N)`\n", + "\n", + "Note: G stands for the smallest common denominator of the nPlanes parameters of\n", + "each shell\n", + "\n", + "Note: N is the number of shells overlapping\n", + "\n", + "Note: i is an index in {0,...,N-1}. each shell should have a distinct i\n", + "\n", + "### W_area\n", + "this parameter determines which degree the planes of the shell span. The longitudes of ascending node are distributed in the range \\[startingW , startingW + W_area\\]." + ] } ], "metadata": { diff --git a/src/ladds/io/SatelliteLoader.cpp b/src/ladds/io/SatelliteLoader.cpp index 8081d63f..83585bd6 100644 --- a/src/ladds/io/SatelliteLoader.cpp +++ b/src/ladds/io/SatelliteLoader.cpp @@ -117,7 +117,7 @@ std::vector SatelliteLoader::loadConstellations(ConfigReader &con constellationTotalNumSatellites, nConstellations); - for (auto &c : constellations) { + for (const auto &c : constellations) { SPDLOG_LOGGER_INFO( logger.get(), "{}: insertion starts at iteration: {}, is fully deployed within {} iterations, inserts {} satellites", diff --git a/src/ladds/particle/Constellation.cpp b/src/ladds/particle/Constellation.cpp index 5493b07a..f36e9838 100644 --- a/src/ladds/particle/Constellation.cpp +++ b/src/ladds/particle/Constellation.cpp @@ -22,11 +22,11 @@ Constellation::Constellation(ConfigReader &constellationConfig, ConfigReader &co deltaT(config.get("sim/deltaT")), /* altitudeSpread = 3 * sigma */ distribution(std::normal_distribution(0, config.get("io/altitudeSpread", 0.0) / 3.0)) { - auto coefficientOfDrag = config.get("sim/prop/coefficientOfDrag"); + const auto coefficientOfDrag = config.get("sim/prop/coefficientOfDrag"); // set constellations insertion start and duration setStartTime(constellationConfig.get("constellation/startTime"), - config.get("sim/referenceTime", "2022/01/01")); + config.get("sim/referenceTime")); setDuration(constellationConfig.get("constellation/duration")); std::vector sats = @@ -40,7 +40,7 @@ Constellation::Constellation(ConfigReader &constellationConfig, ConfigReader &co satellites.push_back(sats[i]); } - int nShells = constellationConfig.get("constellation/nShells"); + const auto nShells = constellationConfig.get("constellation/nShells"); for (int i = 1; i <= nShells; i++) { std::string attribute = "shell" + std::to_string(i); shells.emplace_back>({constellationConfig.get(attribute + "/altitude"), @@ -55,11 +55,12 @@ Constellation::Constellation(ConfigReader &constellationConfig, ConfigReader &co timestamps.reserve(nShells + 1); timestamps.push_back(0); - for (auto [alt, i, planes, nSats] : shells) { + for (const auto [alt, i, planes, nSats] : shells) { timestamp += (planes * nSats / static_cast(constellationSize)) * static_cast(duration); timestamps.push_back(timestamp); } - std::cout << "schedule for " << constellationName << ":" << std::endl; + + // calculate schedule with launch times for each plane in constellation schedule.resize(nShells); for (int i = 0ul; i < timestamps.size() - 1; ++i) { int nPlanes = static_cast(shells[i][2]); @@ -68,19 +69,17 @@ Constellation::Constellation(ConfigReader &constellationConfig, ConfigReader &co schedule[i].reserve(nPlanes); for (int j = 0ul; j < nPlanes; j++) { schedule[i].push_back(timestamps[i] + j * timeStepSize); - std::cout << timestamps[i] + j * timeStepSize << " "; } - std::cout << std::endl; } idBase += 1000000; } -void Constellation::setStartTime(const std::string &startTime_str, const std::string &refTime_str) { +void Constellation::setStartTime(const std::string &startTimeStr, const std::string &refTimeStr) { // date string - if (startTime_str.find('/') != std::string::npos) { - std::array dateArrayStart = parseDatestring(startTime_str); - std::array dateArrayRef = parseDatestring(refTime_str); + if (startTimeStr.find('-') != std::string::npos) { + std::array dateArrayStart = parseDatestring(startTimeStr); + std::array dateArrayRef = parseDatestring(refTimeStr); struct tm stm = {0, 0, 0, dateArrayStart[2], dateArrayStart[1] - 1, dateArrayStart[0]}; struct tm t0 = {0, 0, 0, dateArrayRef[2], dateArrayRef[1] - 1, dateArrayRef[0]}; @@ -89,14 +88,14 @@ void Constellation::setStartTime(const std::string &startTime_str, const std::st return; } // iteration - startTime = std::stoi(startTime_str); + startTime = std::stoi(startTimeStr); } -void Constellation::setDuration(const std::string &duration_str) { - if (duration_str[duration_str.size() - 1] == 'd') { - duration = static_cast(24 * 60 * 60 * std::stoi(duration_str.substr(0, duration_str.size() - 1)) / deltaT); +void Constellation::setDuration(const std::string &durationStr) { + if (durationStr[durationStr.size() - 1] == 'd') { + duration = static_cast(24 * 60 * 60 * std::stoi(durationStr.substr(0, durationStr.size() - 1)) / deltaT); } else { - duration = std::stoi(duration_str); + duration = std::stoi(durationStr); } } @@ -111,14 +110,12 @@ std::vector Constellation::tick() { if (static_cast(simulationTime) >= startTime) { status = Status::active; timeActive = simulationTime - startTime; - std::cout << "timeActive for " << constellationName << ": " << timeActive << std::endl; } else { break; } case Status::active: - + // inserting scheduled particles while (static_cast(timeActive) >= schedule[currentShellIndex][planesDeployed]) { - std::cout << "insertion " << constellationName << ": " << timeActive << std::endl; auto planeSize = static_cast(shells[currentShellIndex][3]); particles.reserve(particles.capacity() + planeSize); for (int i = 0; i < planeSize; i++) { @@ -216,16 +213,13 @@ std::array Constellation::randomDisplacement(const std::array Constellation::parseDatestring(const std::string &date_str) { +std::array Constellation::parseDatestring(const std::string &dateStr) { std::array dateArray{}; - std::string current_str = date_str; - size_t current_idx = current_str.find('/'); - for (int i = 0; i < 3; i++) { - dateArray[i] = std::stoi(current_str.substr(0, current_idx)); - if (i != 2) { - current_str = current_str.erase(0, current_idx + 1); - current_idx = current_str.find('/'); - } + std::string currentStr = dateStr; + for (auto &dateField : dateArray) { + const size_t currentIdx = std::min(currentStr.find('-'), currentStr.size()); + dateField = std::stoi(currentStr.substr(0, currentIdx)); + currentStr = currentStr.erase(0, currentIdx + 1); } return dateArray; } diff --git a/src/ladds/particle/Constellation.h b/src/ladds/particle/Constellation.h index 4ce815b2..7b65603d 100644 --- a/src/ladds/particle/Constellation.h +++ b/src/ladds/particle/Constellation.h @@ -16,9 +16,9 @@ #include "ladds/particle/Particle.h" /** - * The Constellation class contains a collection of Particles that inserts these particles into - * the simulation over time based on .csv files and a .yaml file as created by the - * ConstellationGeneration notebook + * The Constellation class contains a collection of Particles that inserts these into + * the simulation over time, based on .csv files and a .yaml file as created by the + * ConstellationGeneration notebook. */ class Constellation { public: @@ -26,194 +26,191 @@ class Constellation { * Constructs a constellation object * @param constellationConfig : ConfigReader object with the constellation data. Valid * constellation data can be created using the ConstellationGeneration notebook - * and must be in the projects data folder - * @param interval : the interval of satellites being added to the simulation is - * passed for internal logic - * @param altitudeDeviation : used to create satellites with normally distributed - * altitudes. Equals the standard deviation of a normal distribution - * @param coefficientOfDrag c_D used to initialize all satellites. + * and must be placed in the projects data folder. + * @param config : ConfigReader object with the simulation information, reads constellationFrequency, + * deltaT,coefficientOfDrag. */ Constellation(ConfigReader &constellationConfig, ConfigReader &config); /** - * sets internal attribute startTime according to the passed date string - * startTime_str + * Sets internal attribute startTime according to the passed date string + * startTimeStr. * @param startTime a point in time either in iterations or as a date string. if * the string represents a natural number, it is considered as an iteration * and the string is converted to a number, if it is a date string it is converted - * to an iteration timestamp before startTime is set to that value + * to an iteration timestamp before startTime is set to that value. */ - void setStartTime(const std::string &startTime_str, const std::string &refTime_str); + void setStartTime(const std::string &startTimeStr, const std::string &refTimeStr); /** - * sets internal attribute duration according to the passed string parameter - * duration_str - * @param duration_str represents the duration of deployment in either iterations + * Sets internal attribute duration according to the passed string parameter + * durationStr. + * @param durationStr represents the duration of deployment in either iterations * or days. the parameter is considered as a count of days when its last character - * equals 'd' and an iteration count otherwise + * equals 'd' and an iteration count otherwise. */ - void setDuration(const std::string &duration_str); + void setDuration(const std::string &durationStr); /** - * determines which satellites are being added to the simulation by adding each shell + * Determines which satellites are being added to the simulation by adding each shell * within a time span proportional to the shells size. shells are added plane by plane - * and linearly over time - * @return std::vector : satellites to be added to the simulation + * and linearly over time. + * @return std::vector : satellites to be added to the simulation. */ std::vector tick(); /** - * getter for constellationSize = number of satellites in constellation - * @return int : constellationSize + * Getter for constellationSize = number of satellites in constellation. + * @return int : constellationSize. */ [[nodiscard]] size_t getConstellationSize() const; /** - * getter for constellationName = name of this constellation - * @return std::sting : constellationName + * Getter for constellationName = name of this constellation. + * @return std::sting : constellationName. */ [[nodiscard]] std::string getConstellationName() const; /** - * getter for startTime = timestamp (iteration) when constellation insertion starts - * @return size_t : timestamp (iteration) when constellation insertion starts + * Getter for startTime = timestamp (iteration) when constellation insertion starts. + * @return size_t : timestamp (iteration) when constellation insertion starts. */ [[nodiscard]] long getStartTime() const; /** - * getter for duration = timespan over which constellation insertion takes place - * @return size_t : timespan over which constellation insertion takes place + * Getter for duration = timespan over which constellation insertion takes place. + * @return size_t : timespan over which constellation insertion takes place. */ [[nodiscard]] size_t getDuration() const; private: /** - * stores the satellites of the constellation that have not been added to the simulation + * Stores the satellites of the constellation that have not been added to the simulation. */ std::deque satellites{}; /** - * the name of the constellation + * The name of the constellation. */ std::string constellationName; /** * Reads the passed position and velocity csv files. Returns a vector of particles. - * @param position_filepath - * @param velocity_filepath - * @param coefficientOfDrag - * @return + * @param positionFilepath : path to csv file with the satellites' positions. + * @param velocityFilepath : path to csv file with the satellites' velocities. + * @param coefficientOfDrag : coefficient of drag. + * @return vector with Particle objects. */ - static std::vector readDatasetConstellation(const std::string &position_filepath, - const std::string &velocity_filepath, + static std::vector readDatasetConstellation(const std::string &positionFilepath, + const std::string &velocityFilepath, double coefficientOfDrag); /** - * changes the pos vector by adding a random, normal distributed offset to the altitude - * (offset dependent on altitudeVariance) - * @param pos input position - * @return new position with random altitude + * Changes the pos vector by adding a random, normal distributed offset to the altitude + * (offset dependent on altitudeVariance). + * @param pos input position. + * @return New position with random altitude. */ std::array randomDisplacement(const std::array &pos); /** - * parses datestring with expected format // - * @param datestr datestring - * @return integer array with year, month, and day + * Parses datestring with expected format -- + * @param datestr datestring. + * @return Integer array with year, month, and day. */ - static std::array parseDatestring(const std::string &date_str); + static std::array parseDatestring(const std::string &dateStr); /** - * iteration from which constellation starts being added to the simulation + * Iteration from which constellation starts being added to the simulation. */ long startTime = 0; /** - * time span over which satellites of the constellation are being added + * Time span over which satellites of the constellation are being added. (iterations) */ size_t duration = 0; /** - * internal clock that determines which satellites are added to the simulation, - * starts the count when constellation is set to 'a' = active + * Internal clock that determines which satellites are added to the simulation, + * starts the count when constellation is set to 'a' = active. (iterations) */ size_t timeActive = 0; /** - * the interval of satellites being added to the simulation is - * passed for internal logic + * The interval of satellites being added to the simulation is + * passed for internal logic. (iterations) */ size_t interval = 0; /** * deltaT of the simulation passed to constellations for converting datestring time - * into simulation time expressed in iterations + * into simulation time expressed in iterations. (simulation seconds) */ double deltaT; /** - * multiples of interval. the constellations state is set to 'a' = active whenever - * simulationTime reaches startTime + * The constellations state is set to 'a' = active whenever + * simulationTime reaches startTime. (iterations) */ size_t simulationTime = 0; /** * The three different possible internal states of a constellation object: - * inactive: startTime has not been reached yet - * active: the constellation is currently being added to the simulation - * deployed: the constellation is fully deployed, and tick becomes a NOOP + * inactive: startTime has not been reached yet. + * active: the constellation is currently being added to the simulation. + * deployed: the constellation is fully deployed, and tick becomes a NOOP. */ enum Status { inactive, active, deployed }; /** - * variable that holds the internal state of the constellation object that determines + * Variable that holds the internal state of the constellation object that determines * the behaviour of tick(). There are 3 different states: - * inactive: startTime has not been reached yet - * active: the constellation is currently being added to the simulation - * deployed: the constellation is fully deployed, and tick becomes a NOOP + * inactive: startTime has not been reached yet. + * active: the constellation is currently being added to the simulation. + * deployed: the constellation is fully deployed, and tick becomes a NOOP. */ Status status = Status::inactive; // active , inactive ,deployed /** - * size of the constellation for internal use + * Total size of the constellation. Does not change unlike satellites.size() */ size_t constellationSize = 0ul; /** - * contains information of a shell: altitude, inclination, #planes, #satellitesPerPlane + * Contains information of a shell: altitude, inclination, #planes, #satellitesPerPlane. */ std::vector> shells{}; /** - * a vector containing each shells' schedule. if the entry at currentShellIndex and - * planesDeployed is smaller than timeActive the corresponding plane is added + * A vector containing each shells' schedule. if the entry at currentShellIndex and + * planesDeployed is smaller than timeActive the corresponding plane is added. */ std::vector> schedule{}; /** - * keeps track of which shell will be added next + * Keeps track of which shell will be added next. */ size_t currentShellIndex = 0ul; /** - * keeps track of which plane will be added next + * Keeps track of which plane will be added next. */ int planesDeployed = 0; /** - * seeded/deterministic random number generator used to add noise to the - * altitudes of satellites + * Seeded/deterministic random number generator used to add noise to the + * altitudes of satellites. */ static std::mt19937 generator; /** - * normal distribution that determines the deviation of the satellites base - * altitude. uses altitudeDeviation as parameter + * Normal distribution that determines the deviation of the satellites base + * altitude. uses altitudeDeviation as parameter. */ std::normal_distribution distribution; /** - * variable used to give every satellite that is part of a constellation an id + * Variable used to give every satellite that is part of a constellation an id. */ static size_t idBase; }; From 265770a6cc8a23da78951fde1efdadf9140c65c0 Mon Sep 17 00:00:00 2001 From: albertNos Date: Wed, 27 Apr 2022 10:45:29 +0200 Subject: [PATCH 08/11] ID distribution considering constellations --- src/ladds/Simulation.cpp | 25 +++++++++++++- src/ladds/Simulation.h | 8 +++++ src/ladds/particle/BreakupWrapper.h | 7 ++++ src/ladds/particle/Constellation.cpp | 12 ++++--- src/ladds/particle/Constellation.h | 50 +++++++++++++++------------- 5 files changed, 72 insertions(+), 30 deletions(-) diff --git a/src/ladds/Simulation.cpp b/src/ladds/Simulation.cpp index 812e6ee4..8fcd28b4 100644 --- a/src/ladds/Simulation.cpp +++ b/src/ladds/Simulation.cpp @@ -224,9 +224,12 @@ size_t Simulation::simulationLoop(AutoPas_t &autopas, const auto [hdf5WriteFrequency, hdf5Writer, conjuctionWriter] = initWriter(config); + //set constellation particle IDs and fetch maxExistingParticleId + const size_t maxExistingParticleId = setConstellationIDs(autopas,constellations); // only add the breakup model if enabled via yaml const std::unique_ptr breakupWrapper = - config.get("sim/breakup/enabled") ? std::make_unique(config, autopas) : nullptr; + config.get("sim/breakup/enabled") ? std::make_unique(config, autopas, maxExistingParticleId) : nullptr; + const auto timeout = computeTimeout(config); @@ -363,6 +366,26 @@ std::vector Simulation::checkedInsert(autopas::AutoPas &auto return delayedInsertion; } +size_t Simulation::setConstellationIDs(autopas::AutoPas &autopas, std::vector &constellations) { + size_t nextBaseId = 0; + // 1. find highest existing particle id + // Particles are not sorted by id and might neither be starting by 0 nor be consecutive (e.g. due to burn-ups) + // therefore we have to go through all of them + for (const auto &p : autopas) { + nextBaseId = std::max(nextBaseId, p.getID()); + } + nextBaseId += 1; + // 2. distribute globally unique ids for constellation satellites + for(auto &constellation : constellations){ + constellation.moveConstellationIds(nextBaseId); + nextBaseId += constellation.getConstellationSize(); + } + //3. return new maxExistingParticleId + return nextBaseId - 1; + + +} + void Simulation::run(ConfigReader &config) { timers.total.start(); diff --git a/src/ladds/Simulation.h b/src/ladds/Simulation.h index 5d5fa3b9..fe08c19f 100644 --- a/src/ladds/Simulation.h +++ b/src/ladds/Simulation.h @@ -127,6 +127,14 @@ class Simulation { const std::vector &newSatellites, double constellationCutoff); + /** + * Distributes global IDs for all constellation particles and returns the resulting maxExistingParticleId. + * @param autopas + * @param constellations + * @return size_t maxExistingParticleId + */ + size_t setConstellationIDs(autopas::AutoPas &autopas,std::vector &constellations); + /** * Remove all particles below a certain altitude from the particle container. * @param autopas diff --git a/src/ladds/particle/BreakupWrapper.h b/src/ladds/particle/BreakupWrapper.h index c88f0f33..a020f992 100644 --- a/src/ladds/particle/BreakupWrapper.h +++ b/src/ladds/particle/BreakupWrapper.h @@ -33,6 +33,13 @@ class BreakupWrapper { } }; + BreakupWrapper(ConfigReader &config, AutoPas_t &autopas, size_t maxExistingParticleId) + : minLc{config.get("sim/breakup/minLc", 0.01)}, + enforceMassConservation{config.get("sim/breakup/enforceMassConservation", true)}, + coefficientOfDrag{config.get("sim/prop/coefficientOfDrag")}, + maxExistingParticleId{maxExistingParticleId}, + autopas{autopas}{}; + void simulateBreakup(const CollisionFunctor::CollisionCollectionT &collisions); private: diff --git a/src/ladds/particle/Constellation.cpp b/src/ladds/particle/Constellation.cpp index f36e9838..5d327d7f 100644 --- a/src/ladds/particle/Constellation.cpp +++ b/src/ladds/particle/Constellation.cpp @@ -12,8 +12,6 @@ #include #include -size_t Constellation::idBase = 1000000; - std::mt19937 Constellation::generator{42}; Constellation::Constellation(ConfigReader &constellationConfig, ConfigReader &config) @@ -71,8 +69,6 @@ Constellation::Constellation(ConfigReader &constellationConfig, ConfigReader &co schedule[i].push_back(timestamps[i] + j * timeStepSize); } } - - idBase += 1000000; } void Constellation::setStartTime(const std::string &startTimeStr, const std::string &refTimeStr) { @@ -143,6 +139,12 @@ std::vector Constellation::tick() { return particles; } +void Constellation::moveConstellationIds(const size_t baseId) { + for(auto &satellite : satellites) { + satellite.setID(baseId + satellite.getID()); + } +} + size_t Constellation::getConstellationSize() const { return constellationSize; } @@ -162,7 +164,7 @@ size_t Constellation::getDuration() const { std::vector Constellation::readDatasetConstellation(const std::string &position_filepath, const std::string &velocity_filepath, double coefficientOfDrag) { - size_t particleId = idBase; + size_t particleId = 0; CSVReader pos_csvReader{position_filepath, false}; CSVReader vel_csvReader{velocity_filepath, false}; diff --git a/src/ladds/particle/Constellation.h b/src/ladds/particle/Constellation.h index 7b65603d..7214f873 100644 --- a/src/ladds/particle/Constellation.h +++ b/src/ladds/particle/Constellation.h @@ -32,25 +32,6 @@ class Constellation { */ Constellation(ConfigReader &constellationConfig, ConfigReader &config); - /** - * Sets internal attribute startTime according to the passed date string - * startTimeStr. - * @param startTime a point in time either in iterations or as a date string. if - * the string represents a natural number, it is considered as an iteration - * and the string is converted to a number, if it is a date string it is converted - * to an iteration timestamp before startTime is set to that value. - */ - void setStartTime(const std::string &startTimeStr, const std::string &refTimeStr); - - /** - * Sets internal attribute duration according to the passed string parameter - * durationStr. - * @param durationStr represents the duration of deployment in either iterations - * or days. the parameter is considered as a count of days when its last character - * equals 'd' and an iteration count otherwise. - */ - void setDuration(const std::string &durationStr); - /** * Determines which satellites are being added to the simulation by adding each shell * within a time span proportional to the shells size. shells are added plane by plane @@ -59,6 +40,13 @@ class Constellation { */ std::vector tick(); + /** + * Offsets all local constellation IDs by the parameter baseId to create global IDs. + * (globalId = localId + baseId) + * @param baseId + */ + void moveConstellationIds(const size_t baseId); + /** * Getter for constellationSize = number of satellites in constellation. * @return int : constellationSize. @@ -105,6 +93,25 @@ class Constellation { const std::string &velocityFilepath, double coefficientOfDrag); + /** + * Sets internal attribute startTime according to the passed date string + * startTimeStr. + * @param startTime a point in time either in iterations or as a date string. if + * the string represents a natural number, it is considered as an iteration + * and the string is converted to a number, if it is a date string it is converted + * to an iteration timestamp before startTime is set to that value. + */ + void setStartTime(const std::string &startTimeStr, const std::string &refTimeStr); + + /** + * Sets internal attribute duration according to the passed string parameter + * durationStr. + * @param durationStr represents the duration of deployment in either iterations + * or days. the parameter is considered as a count of days when its last character + * equals 'd' and an iteration count otherwise. + */ + void setDuration(const std::string &durationStr); + /** * Changes the pos vector by adding a random, normal distributed offset to the altitude * (offset dependent on altitudeVariance). @@ -208,9 +215,4 @@ class Constellation { * altitude. uses altitudeDeviation as parameter. */ std::normal_distribution distribution; - - /** - * Variable used to give every satellite that is part of a constellation an id. - */ - static size_t idBase; }; From 08ae2769b041e8b3a1f5df24530e8e32fbec0a28 Mon Sep 17 00:00:00 2001 From: albertNos Date: Wed, 27 Apr 2022 10:49:54 +0200 Subject: [PATCH 09/11] cf --- src/ladds/Simulation.cpp | 17 ++++++++--------- src/ladds/Simulation.h | 2 +- src/ladds/particle/BreakupWrapper.h | 2 +- src/ladds/particle/Constellation.cpp | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/ladds/Simulation.cpp b/src/ladds/Simulation.cpp index 8fcd28b4..613b2d28 100644 --- a/src/ladds/Simulation.cpp +++ b/src/ladds/Simulation.cpp @@ -224,12 +224,12 @@ size_t Simulation::simulationLoop(AutoPas_t &autopas, const auto [hdf5WriteFrequency, hdf5Writer, conjuctionWriter] = initWriter(config); - //set constellation particle IDs and fetch maxExistingParticleId - const size_t maxExistingParticleId = setConstellationIDs(autopas,constellations); + // set constellation particle IDs and fetch maxExistingParticleId + const size_t maxExistingParticleId = setConstellationIDs(autopas, constellations); // only add the breakup model if enabled via yaml const std::unique_ptr breakupWrapper = - config.get("sim/breakup/enabled") ? std::make_unique(config, autopas, maxExistingParticleId) : nullptr; - + config.get("sim/breakup/enabled") ? std::make_unique(config, autopas, maxExistingParticleId) + : nullptr; const auto timeout = computeTimeout(config); @@ -366,7 +366,8 @@ std::vector Simulation::checkedInsert(autopas::AutoPas &auto return delayedInsertion; } -size_t Simulation::setConstellationIDs(autopas::AutoPas &autopas, std::vector &constellations) { +size_t Simulation::setConstellationIDs(autopas::AutoPas &autopas, + std::vector &constellations) { size_t nextBaseId = 0; // 1. find highest existing particle id // Particles are not sorted by id and might neither be starting by 0 nor be consecutive (e.g. due to burn-ups) @@ -376,14 +377,12 @@ size_t Simulation::setConstellationIDs(autopas::AutoPas &autopas, std: } nextBaseId += 1; // 2. distribute globally unique ids for constellation satellites - for(auto &constellation : constellations){ + for (auto &constellation : constellations) { constellation.moveConstellationIds(nextBaseId); nextBaseId += constellation.getConstellationSize(); } - //3. return new maxExistingParticleId + // 3. return new maxExistingParticleId return nextBaseId - 1; - - } void Simulation::run(ConfigReader &config) { diff --git a/src/ladds/Simulation.h b/src/ladds/Simulation.h index fe08c19f..7ec078c7 100644 --- a/src/ladds/Simulation.h +++ b/src/ladds/Simulation.h @@ -133,7 +133,7 @@ class Simulation { * @param constellations * @return size_t maxExistingParticleId */ - size_t setConstellationIDs(autopas::AutoPas &autopas,std::vector &constellations); + size_t setConstellationIDs(autopas::AutoPas &autopas, std::vector &constellations); /** * Remove all particles below a certain altitude from the particle container. diff --git a/src/ladds/particle/BreakupWrapper.h b/src/ladds/particle/BreakupWrapper.h index a020f992..8017330d 100644 --- a/src/ladds/particle/BreakupWrapper.h +++ b/src/ladds/particle/BreakupWrapper.h @@ -38,7 +38,7 @@ class BreakupWrapper { enforceMassConservation{config.get("sim/breakup/enforceMassConservation", true)}, coefficientOfDrag{config.get("sim/prop/coefficientOfDrag")}, maxExistingParticleId{maxExistingParticleId}, - autopas{autopas}{}; + autopas{autopas} {}; void simulateBreakup(const CollisionFunctor::CollisionCollectionT &collisions); diff --git a/src/ladds/particle/Constellation.cpp b/src/ladds/particle/Constellation.cpp index 5d327d7f..dd5546ee 100644 --- a/src/ladds/particle/Constellation.cpp +++ b/src/ladds/particle/Constellation.cpp @@ -140,7 +140,7 @@ std::vector Constellation::tick() { } void Constellation::moveConstellationIds(const size_t baseId) { - for(auto &satellite : satellites) { + for (auto &satellite : satellites) { satellite.setID(baseId + satellite.getID()); } } From d42c9ce8c53872b291b1cd8c0f8a05d219564898 Mon Sep 17 00:00:00 2001 From: albertNos Date: Wed, 27 Apr 2022 11:05:28 +0200 Subject: [PATCH 10/11] rename function in constellation class --- src/ladds/Simulation.cpp | 2 +- src/ladds/particle/Constellation.cpp | 2 +- src/ladds/particle/Constellation.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ladds/Simulation.cpp b/src/ladds/Simulation.cpp index 613b2d28..78133031 100644 --- a/src/ladds/Simulation.cpp +++ b/src/ladds/Simulation.cpp @@ -378,7 +378,7 @@ size_t Simulation::setConstellationIDs(autopas::AutoPas &autopas, nextBaseId += 1; // 2. distribute globally unique ids for constellation satellites for (auto &constellation : constellations) { - constellation.moveConstellationIds(nextBaseId); + constellation.moveConstellationIDs(nextBaseId); nextBaseId += constellation.getConstellationSize(); } // 3. return new maxExistingParticleId diff --git a/src/ladds/particle/Constellation.cpp b/src/ladds/particle/Constellation.cpp index dd5546ee..8c0e23f2 100644 --- a/src/ladds/particle/Constellation.cpp +++ b/src/ladds/particle/Constellation.cpp @@ -139,7 +139,7 @@ std::vector Constellation::tick() { return particles; } -void Constellation::moveConstellationIds(const size_t baseId) { +void Constellation::moveConstellationIDs(const size_t baseId) { for (auto &satellite : satellites) { satellite.setID(baseId + satellite.getID()); } diff --git a/src/ladds/particle/Constellation.h b/src/ladds/particle/Constellation.h index 7214f873..775ac2cf 100644 --- a/src/ladds/particle/Constellation.h +++ b/src/ladds/particle/Constellation.h @@ -45,7 +45,7 @@ class Constellation { * (globalId = localId + baseId) * @param baseId */ - void moveConstellationIds(const size_t baseId); + void moveConstellationIDs(const size_t baseId); /** * Getter for constellationSize = number of satellites in constellation. From ffb1ac986ba57b1322706714a2459e8af5bb1dc6 Mon Sep 17 00:00:00 2001 From: FG-TUM Date: Thu, 28 Apr 2022 17:07:57 +0200 Subject: [PATCH 11/11] typo --- cfg/default_cfg.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfg/default_cfg.yaml b/cfg/default_cfg.yaml index 48e521d0..f94d36ac 100644 --- a/cfg/default_cfg.yaml +++ b/cfg/default_cfg.yaml @@ -44,7 +44,7 @@ io: writeFrequency: 1000 # Frequency of writing to the hdf5 file [iterations] compressionLevel: 4 # Valid Levels: 0 (no compression) - 9 (max compression) - #constellationList: AstraPhase2 # ';'-seperated constellations consisting of path (to constellation directory) + #constellationList: AstraPhase2 # ';'-separated constellations consisting of path (to constellation directory) constellationFrequency: 10 # Frequency of adding satellites to simulation [iterations] constellationCutoff: 0.1 # satellites of constellations are only inserted when there is no object within constellationCutoff range altitudeSpread: 1.0 # [km] normal distributed altitude deviations are usually smaller than this value (~99.74% chance)