From 4ce64a5a24dd9479f67797864365f476b8d79a8e Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 16 May 2019 16:01:50 +0200 Subject: [PATCH 01/10] windows compatible version; cmake file is updated --- .gitignore | 340 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ce6fdd --- /dev/null +++ b/.gitignore @@ -0,0 +1,340 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- Backup*.rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb \ No newline at end of file From 954d10c2647de23230fdf39ef14e1181c1378fda Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 16 May 2019 16:04:01 +0200 Subject: [PATCH 02/10] windows compatible version + improved CMakeList.txt --- 2D_DDD_simulation.vcxproj | 81 +++++++++++++++ 2D_DDD_simulation.vcxproj.filters | 90 +++++++++++++++++ CMakeLists.txt | 23 +++-- README.md | 53 ++++++++-- SDDST.sln | 25 +++++ include/Fields/AnalyticField.h | 3 +- include/Fields/PeriodicShearStressELTE.h | 2 +- include/utility.h | 25 +++-- src/bindings.cpp | 2 + src/project_parser.cpp | 122 +++++++++++------------ src/sdddstCMakeConfig.h | 14 +++ src/simulation.cpp | 2 +- 12 files changed, 345 insertions(+), 97 deletions(-) create mode 100644 2D_DDD_simulation.vcxproj create mode 100644 2D_DDD_simulation.vcxproj.filters create mode 100644 SDDST.sln create mode 100644 src/sdddstCMakeConfig.h diff --git a/2D_DDD_simulation.vcxproj b/2D_DDD_simulation.vcxproj new file mode 100644 index 0000000..825d8e6 --- /dev/null +++ b/2D_DDD_simulation.vcxproj @@ -0,0 +1,81 @@ + + + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {75A81D91-0A37-4267-B130-851C16A59F5E} + Win32Proj + 2D_DDD_simulation + + + + Application + true + v142 + + + Application + false + v142 + + + + + + + + + + + + + + + %VCPKG_ROOT%\packages\suitesparse_x64-windows\include\suitesparse;include;$(IncludePath) + + + %VCPKG_ROOT%\packages\suitesparse_x64-windows\include\suitesparse;include;$(IncludePath) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/2D_DDD_simulation.vcxproj.filters b/2D_DDD_simulation.vcxproj.filters new file mode 100644 index 0000000..a35c3bf --- /dev/null +++ b/2D_DDD_simulation.vcxproj.filters @@ -0,0 +1,90 @@ + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Resource Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + + + + {6013aefb-16fa-4271-98ac-dde3f86dde21} + + + {64edc90b-102e-42e6-a58f-608780a2886c} + + + {6834fa22-3c32-484d-8c46-ddd1aaf96a40} + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e959c9..2c14a22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,10 +86,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # is required # Find required packages -find_package(PythonLibs ${PY_VERSION} REQUIRED) - -include_directories(${PYTHON_INCLUDE_DIR}) - + FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options) if(Boost_FOUND) # with SYSTEM the compiler knows that they aren't our headers thus @@ -101,12 +98,18 @@ endif() set(Boost_FOUND FALSE) if (BUILD_PYTHON_BINDINGS) - FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} COMPONENTS system python3) - if(Boost_FOUND) - # with SYSTEM the compiler knows that they aren't our headers thus - # warnings & co. will be omitted - include_directories(SYSTEM ${Boost_INCLUDE_DIR}) - set(BOOST_PYTHON_LIBRARIES ${Boost_LIBRARIES}) + FIND_PACKAGE(PythonLibs ${PY_VERSION} REQUIRED) + if(PYTHONLIBS_FOUND) + include_directories(${PYTHON_INCLUDE_DIR}) + FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} COMPONENTS system python3) + if(Boost_FOUND) + # with SYSTEM the compiler knows that they aren't our headers thus + # warnings & co. will be omitted + include_directories(SYSTEM ${Boost_INCLUDE_DIR}) + set(BOOST_PYTHON_LIBRARIES ${Boost_LIBRARIES}) + else() + set(BUILD_PYTHON_BINDINGS FALSE) + endif() else() set(BUILD_PYTHON_BINDINGS FALSE) endif() diff --git a/README.md b/README.md index a224a93..6aecb1d 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,29 @@ Simple Discrete Dislocation Dynamics Simulation Toolkit ## Short description -This toolkit makes it possible to easily simulate 2D edge dislocation systems where the slip planes are parallel and periodic boundary conditions are applied. The integrator is based on an implicit numerical scheme which makes it possible to keep the -O(N2) complexity which arise from the pair interactions while no dislocation annihilation is required and the runtime is greatly decreased. +This toolkit simulates 2D single slip edge dislocation systems under periodic boundary conditions. The integrator is based on an implicit numerical scheme which makes it possible to keep the +O(*N*2) complexity which arise from the pair interactions while no dislocation annihilation is required and the runtime is greatly decreased. SDDDST is highly modular, it can be easily modified and extended based on the use case where it is needed. The detailed publication of the numerical scheme and the implementation with the achived results will be soon available. ## Build & run -### Dependencies -In order to be able to build the simulator, you will need the following dependencies on your computer: +This project uses several external libraries, such as **umfpack** and **boost** and furthermore, to keep the code simple, some additional include libraries must be set up for your compiler. A convenient Linux-gcc-cmake built procedure (scenario A) is provided along with a Windows-VS-vcpkg built procedure (scenario B). + +### Dependencies: scenario A +This is the Linux-gcc-cmake case. To be able to build the simulator, you will need the following dependencies on your computer: * g++ or clang -* cmake +* cmake (at least version 3.8) * make -* boost +* pyhton3 + * this is only needed if python interface is required in CMakeLists.txt + * this can be found at line 23, `option(BUILD_PYTHON_BINDINGS "Build python interface package" OFF)` + * a system-wide python is required, otherwise, cmake will not find the libs + * using a local (user) version of python is possible: define paths for cmake with the switch `-DPYTHON_LIBRARY=~/.local/lib/libpython` and `-DPYTHON_INCLUDE_DIR=~/.local/include/python3.7m` * umfpack from suitesparse -* gsl +* boost (the program options, and python libraries, if python is required) The build is fairly simple from the root directory of the source: @@ -34,14 +40,41 @@ The resulting binary which can be used to run the simulations: ```bash build/src/sdddst ``` - +You can safely **delete** the files corresponding to scenario B: +* 2D_DDD_simulation.vcxproj +* 2D_DDD_simulation.vcxproj.filters +* 2D_DDD_simulation.vcxproj.user +* SDDST.sln + +### Dependencies: scenario B +This is the Windows-VS-vcpkg case. The project can be compiled for x64 compatible machines only [due to umfpacks's openblas dependency](https://github.com/microsoft/vcpkg/issues/2095), which is available only for x64. Follow these instructions to be able build this project. +1. Install [vcpkg](https://github.com/microsoft/vcpkg) + 1. Open a PowerShell (abbreviated as PS) and first create the directory where you would like to place it. Let's say, `C:\local`, so in PS, execute `mkdir C:\local`. Move there by executing `cd C:\local`. + 2. Download the vcpkg package with git or by downloading it with a browser from [its website](https://github.com/Microsoft/vcpkg). + 3. Extract the files with their parent folder vcpkg-master from the compressed file vcpkg-master.zip. Move it to `C:\local`. Navigate your PS there by `cd vcpkg-master`. + 3. Install the program by executing `.\bootstrap-vcpkg.bat`. The installar may ask for admin privileges. + 4. To use the installed packages automatically, execute `.\vcpkg integrate install`. +2. Install the required dependencies by executing + + 1. `.\vcpkg install boost-program-options:x64-windows` for boost program options, and + 2. `.\vcpkg install suitesparse:x64-windows`, this installs the umfpack. + + These steps may take at least around 10 minutes. +3. In VS, create a new solution for the project. Due to an [issue](https://github.com/microsoft/vcpkg/issues/3417), your compiler probably need be informed about umpack's directory. + 1. With the provided solution the project files, it has been already added by pointing to `%VCPKG_ROOT%`. All you need to do is to add a system variable called VCPKG_ROOT with value pointing to the root directory of vcpkg. In our previous example, it was `C:\local\vcpkg-master`. + 2. If you do not want to or cannot create the system variable, or want to start your solution and project files from zero, you can manually add it to your project settings. Open project 2D_DDD_simulation in the solution SDDST, then open your project properties under Project, \ properties. Go to VC++ Directories and in the Include Directories add `C:\local\vcpkg-master\packages\suitesparse_x64-windows\include\suitesparse`. + +You can safely **delete** building files and folders for scenario A: +* cmake/ +* CMakeLists.txt +* sdddstCMakeConfig.h.in +### Configuration files For the available parameters, check out the help! ```bash ./sdddst --help ``` -### Configuration files To be able to run a simulation, data has to be provided in plain text format. The slip planes of the dislocations are parallel with the x axis and the simulation area is between [-0.5, 0.5] in both directions. Based on that an example configuration file which contains dislocation data: ``` @@ -74,7 +107,7 @@ If a log file is requested, a file will be continously updated during the simula * value of the external stress * computation time between the last two successful steps * accumulated strain -* average v2 +* average *v*2 * energy of the system ### Cutoff multiplier diff --git a/SDDST.sln b/SDDST.sln new file mode 100644 index 0000000..bc9a211 --- /dev/null +++ b/SDDST.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28803.156 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "2D_DDD_simulation", "2D_DDD_simulation.vcxproj", "{75A81D91-0A37-4267-B130-851C16A59F5E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {75A81D91-0A37-4267-B130-851C16A59F5E}.Debug|x64.ActiveCfg = Debug|x64 + {75A81D91-0A37-4267-B130-851C16A59F5E}.Debug|x64.Build.0 = Debug|x64 + {75A81D91-0A37-4267-B130-851C16A59F5E}.Release|x64.ActiveCfg = Release|x64 + {75A81D91-0A37-4267-B130-851C16A59F5E}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1160B3E2-E24B-4F5E-9924-2AA7FD6AB9C0} + EndGlobalSection +EndGlobal diff --git a/include/Fields/AnalyticField.h b/include/Fields/AnalyticField.h index 8a8658a..575a039 100644 --- a/include/Fields/AnalyticField.h +++ b/include/Fields/AnalyticField.h @@ -23,7 +23,8 @@ #include "Fields/Field.h" #include "constants.h" -#include +#define _USE_MATH_DEFINES +#include namespace sdddstCore { diff --git a/include/Fields/PeriodicShearStressELTE.h b/include/Fields/PeriodicShearStressELTE.h index fdae996..51cc5f1 100644 --- a/include/Fields/PeriodicShearStressELTE.h +++ b/include/Fields/PeriodicShearStressELTE.h @@ -34,7 +34,7 @@ #include #include -#include +//#include #include "Fields/Field.h" diff --git a/include/utility.h b/include/utility.h index 2ce9188..c6e194c 100644 --- a/include/utility.h +++ b/include/utility.h @@ -20,9 +20,10 @@ #ifndef SDDDST_CORE_UTILITY_H #define SDDDST_CORE_UTILITY_H -#include -#include -#include +#define _USE_MATH_DEFINES +#include +#include +#include inline void normalize(double &n) { @@ -72,19 +73,17 @@ inline double E_dx(const double & x, const double & y, const double & K) // https://stackoverflow.com/questions/17432502/how-can-i-measure-cpu-time-and-wall-clock-time-on-both-linux-windows inline double get_wall_time() { - struct timeval time; - if (gettimeofday(&time, NULL)){ - // Handle error - return 0; - } - return (double)time.tv_sec + (double)time.tv_usec * .000001; + auto t_start = std::chrono::high_resolution_clock::now(); + auto t_start_ms = std::chrono::time_point_cast(t_start); + auto t_start_se = t_start_ms.time_since_epoch(); + + double time_in_ms = static_cast(t_start_se.count()); + + return time_in_ms / 1000.; } // From: // https://stackoverflow.com/questions/17432502/how-can-i-measure-cpu-time-and-wall-clock-time-on-both-linux-windows -inline double get_cpu_time() -{ - return (double)clock() / CLOCKS_PER_SEC; -} + #endif diff --git a/src/bindings.cpp b/src/bindings.cpp index ce99d4d..e7dc6ec 100644 --- a/src/bindings.cpp +++ b/src/bindings.cpp @@ -17,6 +17,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + /* #include "sdddstCMakeConfig.h" #include "dislocation.h" @@ -208,3 +209,4 @@ def("get_cpu_time", &get_cpu_time); class_>("DoubleVector") .def(vector_indexing_suite>()); } +*/ \ No newline at end of file diff --git a/src/project_parser.cpp b/src/project_parser.cpp index 5937dd4..59d8bdc 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -29,76 +29,76 @@ sdddstCore::ProjectParser::ProjectParser(int argc, char **argv): sD(nullptr) { - boost::program_options::options_description requiredOptions("Required Options"); - boost::program_options::options_description optionalOptions("Optional Options"); - boost::program_options::options_description fieldOptions("Available dislocation fields"); - boost::program_options::options_description externalStressProtocolOptions("External stress protocols (optional)"); - - requiredOptions.add_options() - ("dislocation-configuration", boost::program_options::value(), "plain text file path containing dislocation data in {x y b} triplets") - ("result-dislocation-configuration", boost::program_options::value(), "path where the result configuration will be stored at the end of the simulation") - ; - - optionalOptions.add_options() - ("point-defect-configuration", boost::program_options::value(), "plain text file path containing point defect data in {x y} pairs") - ("logfile-path", boost::program_options::value(), "path for the plain text log file (it will be overwritten if it already exists)") - ("time-limit", boost::program_options::value(), "in simulation time limit, if reached the simulation stops") - ("step-count-limit", boost::program_options::value(), "the simulation will stop after successful N steps") - ("strain-increase-limit", boost::program_options::value(), "the simulation will stop after arg total strain increase is reached") - ("avalanche-detection-limit", boost::program_options::value(), "the simulation will stop after the threshold was reached with the given numer of events from above") - ("avalanche-speed-threshold", boost::program_options::value()->default_value(1e-3), "speed threshold for counting avalanches") - ("initial-stepsize", boost::program_options::value()->default_value(1e-6), "first tried step size for the simulation") - ("cutoff-multiplier", boost::program_options::value()->default_value(1e20), "multiplier of the 1/sqrt(N) cutoff parameter") - ("max-stepsize", boost::program_options::value(), "the stepsize can not overleap this value") - ("calculate-strain", "turns on strain calculation for the simulation") - ("calculate-order-parameter", "turns on order parameter calculation during the simulation") - ("position-precision", boost::program_options::value()->default_value(1e-5), "minimum precision for the positions for the adaptive step size protocol") - ("save-sub-configurations", boost::program_options::value(), "saves the current configuration after every N successful step to the given destination") - ("sub-configuration-delay", boost::program_options::value()->default_value(5), "number of successful steps between the sub configurations written out") - ("sub-configuration-delay-during-avalanche", boost::program_options::value()->default_value(1), "number of successful steps between the sub configurations written out during avalanche if avalanche detection is on") - ; - - fieldOptions.add_options() - ("periodic-stress-field-elte", boost::program_options::value()->default_value("."), "periodic stress field based on ELTE library, the argument should be the folder where the compressed numerical data can be found (default)") - ("periodic-stress-field-analytic", ("analytic periodic stress field, number of images in each direction: " + std::to_string(ANALYTIC_FIELD_N)).c_str()) - ; + boost::program_options::options_description requiredOptions("Required Options"); // must be set from command line or file + boost::program_options::options_description optionalOptions("Optional Options"); // either has value or program runs without them + boost::program_options::options_description fieldOptions("Available dislocation fields"); // how the interaction force should be calculated: lookup table or calculation + boost::program_options::options_description externalStressProtocolOptions("External stress protocols (optional)"); // how the external stress should increase + + requiredOptions.add_options() + ("dislocation-configuration", boost::program_options::value(), "plain text file path containing dislocation data in {x y b} triplets") + ("result-dislocation-configuration", boost::program_options::value(), "path where the result configuration will be stored at the end of the simulation") + ; + + optionalOptions.add_options() + ("point-defect-configuration", boost::program_options::value(), "plain text file path containing point defect data in {x y} pairs") + ("logfile-path", boost::program_options::value(), "path for the plain text log file (it will be overwritten if it already exists)") + ("time-limit", boost::program_options::value(), "in simulation time limit, if reached the simulation stops") + ("step-count-limit", boost::program_options::value(), "the simulation will stop after successful N steps") + ("strain-increase-limit", boost::program_options::value(), "the simulation will stop after arg total strain increase is reached") + ("avalanche-detection-limit", boost::program_options::value(), "the simulation will stop after the threshold was reached with the given numer of events from above") + ("avalanche-speed-threshold", boost::program_options::value()->default_value(1e-3), "speed threshold for counting avalanches") + ("initial-stepsize", boost::program_options::value()->default_value(1e-6), "first tried step size for the simulation") + ("cutoff-multiplier", boost::program_options::value()->default_value(1e20), "multiplier of the 1/sqrt(N) cutoff parameter") + ("max-stepsize", boost::program_options::value(), "the stepsize can not overleap this value") + ("calculate-strain", "turns on strain calculation for the simulation") + ("calculate-order-parameter", "turns on order parameter calculation during the simulation") + ("position-precision", boost::program_options::value()->default_value(1e-5), "minimum precision for the positions for the adaptive step size protocol") + ("save-sub-configurations", boost::program_options::value(), "saves the current configuration after every N successful step to the given destination") + ("sub-configuration-delay", boost::program_options::value()->default_value(5), "number of successful steps between the sub configurations written out") + ("sub-configuration-delay-during-avalanche", boost::program_options::value()->default_value(1), "number of successful steps between the sub configurations written out during avalanche if avalanche detection is on") + ; + + fieldOptions.add_options() + ("periodic-stress-field-elte", boost::program_options::value()->default_value("."), "periodic stress field based on ELTE library, the argument should be the folder where the compressed numerical data can be found (default)") + ("periodic-stress-field-analytic", ("analytic periodic stress field, number of images in each direction: " + std::to_string(ANALYTIC_FIELD_N)).c_str()) + ; externalStressProtocolOptions.add_options() - ("no-external-stress", "no external stress during the simulation (default)") - ("fixed-rate-external-stress", boost::program_options::value(), "external stress is linear with time, rate should be specified as an arg") - ("spring-constant", boost::program_options::value(), "simple model of an experiment where a spring is used, the arg should be the spring constant (it is valid only with the previous option together)") - ; + ("no-external-stress", "no external stress during the simulation (default)") + ("fixed-rate-external-stress", boost::program_options::value(), "external stress is linear with time, rate should be specified as an arg") + ("spring-constant", boost::program_options::value(), "simple model of an experiment where a spring is used, the arg should be the spring constant (it is valid only with the previous option together)") + ; boost::program_options::options_description options; options.add(requiredOptions).add(optionalOptions).add(fieldOptions).add(externalStressProtocolOptions).add_options() - ("help", "show this help") - ("hide-copyright,c", "hides the copyright notice from the standard output"); + ("help", "show this help") + ("hide-copyright,c", "hides the copyright notice from the standard output"); boost::program_options::variables_map vm; - try{ - boost::program_options::store(boost::program_options::parse_command_line(argc, argv, options), vm, true); - } - catch(boost::program_options::error & e) - { - std::cerr << e.what() << std::endl; - exit(-1); - } - - if (!vm.count("hide-copyright")) - { - printLicense(); - } - if (vm.count("help")) - { - std::cout << options << std::endl; - exit(0); - } - else - { - processInput(vm); - } + try { + boost::program_options::store(boost::program_options::parse_command_line(argc, argv, options), vm, true); + } + catch (boost::program_options::error & e) + { + std::cerr << e.what() << std::endl; + exit(-1); + } + + if (!vm.count("hide-copyright")) + { + printLicense(); + } + if (vm.count("help")) + { + std::cout << options << std::endl; + exit(0); + } + else + { + processInput(vm); + } } sdddstCore::ProjectParser::~ProjectParser() diff --git a/src/sdddstCMakeConfig.h b/src/sdddstCMakeConfig.h new file mode 100644 index 0000000..c4fa43d --- /dev/null +++ b/src/sdddstCMakeConfig.h @@ -0,0 +1,14 @@ +/* Include the options set in CMakeLists.txt + * and other project related settings + */ +#define SDDDST_VERSION_MAJOR "@sdddst_VERSION_MAJOR@" +#define SDDDST_VERSION_MINOR "@sdddst_VERSION_MINOR@" + +#define SDDDST_NAME "@PROJECT_NAME@" + +#define PYTHON_LIB_NAME @PYTHON_LIB_NAME@ + +#if 1 == @sdddst_VERBOSE@ + #define SDDDST_VERBOSE +#endif + diff --git a/src/simulation.cpp b/src/simulation.cpp index 2244084..3aacc0c 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -357,7 +357,7 @@ void Simulation::solveEQSys() void Simulation::calculateXError() { - for (size_t i = 0; i < sD->dc; i++) + for (unsigned int i = 0; i < sD->dc; i++) { double tmp = fabs(sD->bigStep[i].x - sD->secondSmall[i].x); pH->updateError(tmp, i); From 6b0b2a1c7f7d47a535f096a4f4292361534dbc4c Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 16 May 2019 16:56:54 +0200 Subject: [PATCH 03/10] tabs swtiched back to 4 spaces --- src/project_parser.cpp | 112 ++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/src/project_parser.cpp b/src/project_parser.cpp index 59d8bdc..87eb693 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -34,71 +34,71 @@ sdddstCore::ProjectParser::ProjectParser(int argc, char **argv): boost::program_options::options_description fieldOptions("Available dislocation fields"); // how the interaction force should be calculated: lookup table or calculation boost::program_options::options_description externalStressProtocolOptions("External stress protocols (optional)"); // how the external stress should increase - requiredOptions.add_options() - ("dislocation-configuration", boost::program_options::value(), "plain text file path containing dislocation data in {x y b} triplets") - ("result-dislocation-configuration", boost::program_options::value(), "path where the result configuration will be stored at the end of the simulation") - ; - - optionalOptions.add_options() - ("point-defect-configuration", boost::program_options::value(), "plain text file path containing point defect data in {x y} pairs") - ("logfile-path", boost::program_options::value(), "path for the plain text log file (it will be overwritten if it already exists)") - ("time-limit", boost::program_options::value(), "in simulation time limit, if reached the simulation stops") - ("step-count-limit", boost::program_options::value(), "the simulation will stop after successful N steps") - ("strain-increase-limit", boost::program_options::value(), "the simulation will stop after arg total strain increase is reached") - ("avalanche-detection-limit", boost::program_options::value(), "the simulation will stop after the threshold was reached with the given numer of events from above") - ("avalanche-speed-threshold", boost::program_options::value()->default_value(1e-3), "speed threshold for counting avalanches") - ("initial-stepsize", boost::program_options::value()->default_value(1e-6), "first tried step size for the simulation") - ("cutoff-multiplier", boost::program_options::value()->default_value(1e20), "multiplier of the 1/sqrt(N) cutoff parameter") - ("max-stepsize", boost::program_options::value(), "the stepsize can not overleap this value") - ("calculate-strain", "turns on strain calculation for the simulation") - ("calculate-order-parameter", "turns on order parameter calculation during the simulation") - ("position-precision", boost::program_options::value()->default_value(1e-5), "minimum precision for the positions for the adaptive step size protocol") - ("save-sub-configurations", boost::program_options::value(), "saves the current configuration after every N successful step to the given destination") - ("sub-configuration-delay", boost::program_options::value()->default_value(5), "number of successful steps between the sub configurations written out") - ("sub-configuration-delay-during-avalanche", boost::program_options::value()->default_value(1), "number of successful steps between the sub configurations written out during avalanche if avalanche detection is on") - ; - - fieldOptions.add_options() - ("periodic-stress-field-elte", boost::program_options::value()->default_value("."), "periodic stress field based on ELTE library, the argument should be the folder where the compressed numerical data can be found (default)") - ("periodic-stress-field-analytic", ("analytic periodic stress field, number of images in each direction: " + std::to_string(ANALYTIC_FIELD_N)).c_str()) - ; + requiredOptions.add_options() + ("dislocation-configuration", boost::program_options::value(), "plain text file path containing dislocation data in {x y b} triplets") + ("result-dislocation-configuration", boost::program_options::value(), "path where the result configuration will be stored at the end of the simulation") + ; + + optionalOptions.add_options() + ("point-defect-configuration", boost::program_options::value(), "plain text file path containing point defect data in {x y} pairs") + ("logfile-path", boost::program_options::value(), "path for the plain text log file (it will be overwritten if it already exists)") + ("time-limit", boost::program_options::value(), "in simulation time limit, if reached the simulation stops") + ("step-count-limit", boost::program_options::value(), "the simulation will stop after successful N steps") + ("strain-increase-limit", boost::program_options::value(), "the simulation will stop after arg total strain increase is reached") + ("avalanche-detection-limit", boost::program_options::value(), "the simulation will stop after the threshold was reached with the given numer of events from above") + ("avalanche-speed-threshold", boost::program_options::value()->default_value(1e-3), "speed threshold for counting avalanches") + ("initial-stepsize", boost::program_options::value()->default_value(1e-6), "first tried step size for the simulation") + ("cutoff-multiplier", boost::program_options::value()->default_value(1e20), "multiplier of the 1/sqrt(N) cutoff parameter") + ("max-stepsize", boost::program_options::value(), "the stepsize can not overleap this value") + ("calculate-strain", "turns on strain calculation for the simulation") + ("calculate-order-parameter", "turns on order parameter calculation during the simulation") + ("position-precision", boost::program_options::value()->default_value(1e-5), "minimum precision for the positions for the adaptive step size protocol") + ("save-sub-configurations", boost::program_options::value(), "saves the current configuration after every N successful step to the given destination") + ("sub-configuration-delay", boost::program_options::value()->default_value(5), "number of successful steps between the sub configurations written out") + ("sub-configuration-delay-during-avalanche", boost::program_options::value()->default_value(1), "number of successful steps between the sub configurations written out during avalanche if avalanche detection is on") + ; + + fieldOptions.add_options() + ("periodic-stress-field-elte", boost::program_options::value()->default_value("."), "periodic stress field based on ELTE library, the argument should be the folder where the compressed numerical data can be found (default)") + ("periodic-stress-field-analytic", ("analytic periodic stress field, number of images in each direction: " + std::to_string(ANALYTIC_FIELD_N)).c_str()) + ; externalStressProtocolOptions.add_options() - ("no-external-stress", "no external stress during the simulation (default)") - ("fixed-rate-external-stress", boost::program_options::value(), "external stress is linear with time, rate should be specified as an arg") - ("spring-constant", boost::program_options::value(), "simple model of an experiment where a spring is used, the arg should be the spring constant (it is valid only with the previous option together)") - ; + ("no-external-stress", "no external stress during the simulation (default)") + ("fixed-rate-external-stress", boost::program_options::value(), "external stress is linear with time, rate should be specified as an arg") + ("spring-constant", boost::program_options::value(), "simple model of an experiment where a spring is used, the arg should be the spring constant (it is valid only with the previous option together)") + ; boost::program_options::options_description options; options.add(requiredOptions).add(optionalOptions).add(fieldOptions).add(externalStressProtocolOptions).add_options() - ("help", "show this help") - ("hide-copyright,c", "hides the copyright notice from the standard output"); + ("help", "show this help") + ("hide-copyright,c", "hides the copyright notice from the standard output"); boost::program_options::variables_map vm; - try { - boost::program_options::store(boost::program_options::parse_command_line(argc, argv, options), vm, true); - } - catch (boost::program_options::error & e) - { - std::cerr << e.what() << std::endl; - exit(-1); - } - - if (!vm.count("hide-copyright")) - { - printLicense(); - } - if (vm.count("help")) - { - std::cout << options << std::endl; - exit(0); - } - else - { - processInput(vm); - } + try { + boost::program_options::store(boost::program_options::parse_command_line(argc, argv, options), vm, true); + } + catch (boost::program_options::error & e) + { + std::cerr << e.what() << std::endl; + exit(-1); + } + + if (!vm.count("hide-copyright")) + { + printLicense(); + } + if (vm.count("help")) + { + std::cout << options << std::endl; + exit(0); + } + else + { + processInput(vm); + } } sdddstCore::ProjectParser::~ProjectParser() From 9d47d50ded589e5bfe540dda487676360fc3c293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20T=C3=BCzes?= Date: Thu, 16 May 2019 17:42:15 +0200 Subject: [PATCH 04/10] python3-dev --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6aecb1d..a58f09a 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ This is the Linux-gcc-cmake case. To be able to build the simulator, you will ne * g++ or clang * cmake (at least version 3.8) * make -* pyhton3 - * this is only needed if python interface is required in CMakeLists.txt - * this can be found at line 23, `option(BUILD_PYTHON_BINDINGS "Build python interface package" OFF)` - * a system-wide python is required, otherwise, cmake will not find the libs - * using a local (user) version of python is possible: define paths for cmake with the switch `-DPYTHON_LIBRARY=~/.local/lib/libpython` and `-DPYTHON_INCLUDE_DIR=~/.local/include/python3.7m` +* pyhton3 with python3-dev + * this is only needed if python interface is required in `CMakeLists.txt` + * this can be found at line 23: `option(BUILD_PYTHON_BINDINGS "Build python interface package" OFF)` + * a system-wide installation is required by default, otherwise, cmake will not find the libs + * using a local (user) version of python is also possible: define paths for cmake with the switch `-DPYTHON_LIBRARY=~/.local/lib/libpython` and `-DPYTHON_INCLUDE_DIR=~/.local/include/python3.7m` if you installed python3-dev into your `$HOME/.local` directory * umfpack from suitesparse * boost (the program options, and python libraries, if python is required) From 5ff530104c01e52f8af0f1be4e26a30e807e3293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20T=C3=BCzes?= Date: Thu, 16 May 2019 21:18:15 +0200 Subject: [PATCH 05/10] random initial state generator --- README.md | 16 ++- SDDST.sln | 6 + init_config_gen/README.md | 25 ++++ init_config_gen/init_config_gen.cpp | 111 ++++++++++++++++++ init_config_gen/init_config_gen.vcxproj | 95 +++++++++++++++ .../init_config_gen.vcxproj.filters | 25 ++++ src/bindings.cpp | 3 +- src/project_parser.cpp | 8 +- 8 files changed, 279 insertions(+), 10 deletions(-) create mode 100644 init_config_gen/README.md create mode 100644 init_config_gen/init_config_gen.cpp create mode 100644 init_config_gen/init_config_gen.vcxproj create mode 100644 init_config_gen/init_config_gen.vcxproj.filters diff --git a/README.md b/README.md index a58f09a..907b4d7 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,21 @@ Simple Discrete Dislocation Dynamics Simulation Toolkit ## Short description -This toolkit simulates 2D single slip edge dislocation systems under periodic boundary conditions. The integrator is based on an implicit numerical scheme which makes it possible to keep the +This toolkit contains tools to simulate 2D single slip edge dislocation systems under periodic boundary conditions. The integrator is based on an implicit numerical scheme which makes it possible to keep the O(*N*2) complexity which arise from the pair interactions while no dislocation annihilation is required and the runtime is greatly decreased. SDDDST is highly modular, it can be easily modified and extended based on the use case where it is needed. The detailed publication of the numerical scheme and the implementation with the achived results will be soon available. +### Tools +The toolkit contains the following tools +1. The **simulation program** *2D_DDD_simulation* that evols the dislocation configuration under the prescribed external stress. +2. [**Dislocation system generator** *init_config_gen*](https://github.com/danieltuzes/sdddst/init_config_gen) to create the initial configuration. +3. **Evaulation programs** to do perform analysis on the simulations obatined. + +The rest of this file belongs to the simulation program 2D_DDD_simulation. + ## Build & run This project uses several external libraries, such as **umfpack** and **boost** and furthermore, to keep the code simple, some additional include libraries must be set up for your compiler. A convenient Linux-gcc-cmake built procedure (scenario A) is provided along with a Windows-VS-vcpkg built procedure (scenario B). @@ -47,20 +55,20 @@ You can safely **delete** the files corresponding to scenario B: * SDDST.sln ### Dependencies: scenario B -This is the Windows-VS-vcpkg case. The project can be compiled for x64 compatible machines only [due to umfpacks's openblas dependency](https://github.com/microsoft/vcpkg/issues/2095), which is available only for x64. Follow these instructions to be able build this project. +This is the Windows-VS-vcpkg case. The project can be compiled for x64 compatible machines only [due to umfpacks's openblas dependency](https://github.com/microsoft/vcpkg/issues/2095), which is available only for x64. This case comes with no python interface yet. Follow these instructions to be able build this project. 1. Install [vcpkg](https://github.com/microsoft/vcpkg) 1. Open a PowerShell (abbreviated as PS) and first create the directory where you would like to place it. Let's say, `C:\local`, so in PS, execute `mkdir C:\local`. Move there by executing `cd C:\local`. 2. Download the vcpkg package with git or by downloading it with a browser from [its website](https://github.com/Microsoft/vcpkg). 3. Extract the files with their parent folder vcpkg-master from the compressed file vcpkg-master.zip. Move it to `C:\local`. Navigate your PS there by `cd vcpkg-master`. 3. Install the program by executing `.\bootstrap-vcpkg.bat`. The installar may ask for admin privileges. 4. To use the installed packages automatically, execute `.\vcpkg integrate install`. -2. Install the required dependencies by executing +2. Install the required dependencies with *vcpkg* by executing 1. `.\vcpkg install boost-program-options:x64-windows` for boost program options, and 2. `.\vcpkg install suitesparse:x64-windows`, this installs the umfpack. These steps may take at least around 10 minutes. -3. In VS, create a new solution for the project. Due to an [issue](https://github.com/microsoft/vcpkg/issues/3417), your compiler probably need be informed about umpack's directory. +3. Use the solution file or set up a new one for the project. Due to an [issue](https://github.com/microsoft/vcpkg/issues/3417), your compiler probably need be informed about umpack's directory. 1. With the provided solution the project files, it has been already added by pointing to `%VCPKG_ROOT%`. All you need to do is to add a system variable called VCPKG_ROOT with value pointing to the root directory of vcpkg. In our previous example, it was `C:\local\vcpkg-master`. 2. If you do not want to or cannot create the system variable, or want to start your solution and project files from zero, you can manually add it to your project settings. Open project 2D_DDD_simulation in the solution SDDST, then open your project properties under Project, \ properties. Go to VC++ Directories and in the Include Directories add `C:\local\vcpkg-master\packages\suitesparse_x64-windows\include\suitesparse`. diff --git a/SDDST.sln b/SDDST.sln index bc9a211..c919027 100644 --- a/SDDST.sln +++ b/SDDST.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.28803.156 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "2D_DDD_simulation", "2D_DDD_simulation.vcxproj", "{75A81D91-0A37-4267-B130-851C16A59F5E}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "init_config_gen", "init_config_gen\init_config_gen.vcxproj", "{4234E9E2-9233-443B-A8DC-B66EDD59BBFD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -15,6 +17,10 @@ Global {75A81D91-0A37-4267-B130-851C16A59F5E}.Debug|x64.Build.0 = Debug|x64 {75A81D91-0A37-4267-B130-851C16A59F5E}.Release|x64.ActiveCfg = Release|x64 {75A81D91-0A37-4267-B130-851C16A59F5E}.Release|x64.Build.0 = Release|x64 + {4234E9E2-9233-443B-A8DC-B66EDD59BBFD}.Debug|x64.ActiveCfg = Debug|x64 + {4234E9E2-9233-443B-A8DC-B66EDD59BBFD}.Debug|x64.Build.0 = Debug|x64 + {4234E9E2-9233-443B-A8DC-B66EDD59BBFD}.Release|x64.ActiveCfg = Release|x64 + {4234E9E2-9233-443B-A8DC-B66EDD59BBFD}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/init_config_gen/README.md b/init_config_gen/README.md new file mode 100644 index 0000000..b9bf6be --- /dev/null +++ b/init_config_gen/README.md @@ -0,0 +1,25 @@ +# SDDDST::init_config_gen +The initial configuration generator tool for Simple Discrete Dislocation Dynamics Simulation Toolkit + +## Short description +With this tool one can create dislocation configurations to use as an input of the simulation program 2D_DDD_simulation. + +## Dependencies +There is 1 new dependencie: `boost.random`. To compile this project you need boost's program options and random libraries. The first is already a requirement for the project *2D_DDD_simulation*. + +## Usage +Type `2D_DDD_simulation --help` to get the help. The program accepts the following arguments: +* `--N arg`: mandatory argument. The number of dislocations to simulate. Must be an even number, because the same amount of positive and negative dislocations must be found in the system. +* `--seed-start arg`: optional argument with default value `1000`. It is an integer used to populate the seed value of the random number generator. +* `--seed-end arg`: optional argument. If set, must be larger than `seed_start` and the program will create configuration files starting from seed value `seed-start`, increasing it one by one till it reaches `seed-end` (closed interval). + +## Output +The program creates the initial conditions in the folder `dislocation-configurations` relative to the binary, with filenames `init_config_SEEDVALUE.txt`. The file format is as described in [SDSST](https://github.com/danieltuzes/sdddst). The output is a simple text file in the format +``` +pos_1_x pos_1_y burgers_vector_1 +pos_2_x pos_2_y burgers_vector_2 +... +pos_N_x pos_N_y burgers_vector_N + +``` +with alternating Burger's vector. Please keep in mind that line endings (`CR` and `LF`) will depend on your operating system. \ No newline at end of file diff --git a/init_config_gen/init_config_gen.cpp b/init_config_gen/init_config_gen.cpp new file mode 100644 index 0000000..32ace38 --- /dev/null +++ b/init_config_gen/init_config_gen.cpp @@ -0,0 +1,111 @@ +// init_config_gen.cpp : This file contains the 'main' function. Program execution begins and ends there. +// + +#include // to read in program call arguments +#include // to add descriptions of the program call arguments +#include // random number generator +#include // uniform distribution generator + +#include +#include + +namespace bpo = boost::program_options; +namespace br = boost::random; +int main(int argc, char** argv) +{ +#pragma region read in variables + std::cout << 1 + 1; + bpo::options_description requiredOptions("Required options"); // must be set from command line or file + bpo::options_description optionalOptions("Seed options"); // must be set from command line or file + + requiredOptions.add_options() + ("N", bpo::value(), "The number of dislocations to generate. Must be even, because N/2 number of positive and negative dislocations will be created."); + + optionalOptions.add_options() + ("seed-start", bpo::value()->default_value(1000), "An integer used as an initial seed value for the random number generator.") + ("seed-end", bpo::value(), "An integer used as the last seed value for the random number generator, seed-end > seed_start must hold. If set, seed-end - seed-start number of initial configurations will be created.") + ; + + bpo::options_description options; // the superior container of the options + + options.add(requiredOptions).add(optionalOptions).add_options() + ("help", "show this help") + ("hide-copyright,c", "hides the copyright notice from the standard output"); + + bpo::variables_map vm; // the storage for the variables + + try { + bpo::store(bpo::parse_command_line(argc, argv, options), vm, false); + } + catch (bpo::error & e) + { + std::cerr << e.what() << std::endl; + exit(-1); + } + + if (!vm.count("hide-copyright")) + { + std::cout << "init_config_gen from the SDDDST - Simple Discrete Dislocation Dynamics Toolkit\n" + "Copyright (C) 2015-2019 Gabor Peterffy , Daniel Tuzes and their friends.\n" + "This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions; see the license for details\n"; + } +#pragma endregion + +#pragma region process variables + if (vm.count("help")) // if the user is curious + { + std::cout << options << std::endl; + exit(0); + } + else // real process is needed + { + // N + if (0 == vm.count("N")) // to test if N is present + { + std::cerr << "N is missing! Program terminates.\n"; + exit(-1); + } + if (vm["N"].as() % 2 != 0) // to test if N is even + { + std::cerr << "N must be even. Program terminates." << std::endl; + exit(-1); + } + + // seed-end >? seed-start + if (vm.count("seed-end") != 0 && vm["seed-end"].as() <= vm["seed-start"].as()) + { + std::cerr << "seed-end > seed-start must hold. Program terminates." << std::endl; + exit(-1); + } + } +#pragma endregion + +#pragma region generate and write out configuration + int seed_val = vm["seed-start"].as(); + int seed_end = (vm.count("seed-end") == 0 ? seed_val : vm["seed-end"].as()); + for (;seed_val <= seed_end; ++seed_val) + { + std::string ofname = "dislocation-configurations/init_config_" +std::to_string(seed_val) + ".txt"; + std::ofstream ofile(ofname); + if (!ofile) + { + std::cerr << "Cannot write " << ofname << ". Program terminates." << std::endl; + exit(-1); + } + std::cout << "Generating configuration with seed value " << seed_val << "." << std::endl; + ofile.precision(std::numeric_limits::max_digits10); // print out every digits + + br::mt19937 generator(seed_val); + br::uniform_real_distribution<> distribution(-0.5, 0.5); + for (int n = 0; n < vm["N"].as(); ++n) + ofile << distribution(generator) + << "\t" << distribution(generator) + << "\t" << (n % 2) * 2 - 1 + << "\n"; + } +#pragma endregion + + + std::cout << "Done.\n"; + return 0; +} \ No newline at end of file diff --git a/init_config_gen/init_config_gen.vcxproj b/init_config_gen/init_config_gen.vcxproj new file mode 100644 index 0000000..350a44c --- /dev/null +++ b/init_config_gen/init_config_gen.vcxproj @@ -0,0 +1,95 @@ + + + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {4234E9E2-9233-443B-A8DC-B66EDD59BBFD} + Win32Proj + initconfiggen + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + + + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/init_config_gen/init_config_gen.vcxproj.filters b/init_config_gen/init_config_gen.vcxproj.filters new file mode 100644 index 0000000..6c642da --- /dev/null +++ b/init_config_gen/init_config_gen.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + + \ No newline at end of file diff --git a/src/bindings.cpp b/src/bindings.cpp index e7dc6ec..85049f6 100644 --- a/src/bindings.cpp +++ b/src/bindings.cpp @@ -17,7 +17,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - /* + #include "sdddstCMakeConfig.h" #include "dislocation.h" @@ -209,4 +209,3 @@ def("get_cpu_time", &get_cpu_time); class_>("DoubleVector") .def(vector_indexing_suite>()); } -*/ \ No newline at end of file diff --git a/src/project_parser.cpp b/src/project_parser.cpp index 87eb693..aefaeb0 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -86,16 +86,16 @@ sdddstCore::ProjectParser::ProjectParser(int argc, char **argv): exit(-1); } - if (!vm.count("hide-copyright")) + if (!vm.count("hide-copyright")) // if the user doesn't hide the bloaty copyright text { printLicense(); } - if (vm.count("help")) + if (vm.count("help")) // if the user only interested in the help, there is no need to check the variables { std::cout << options << std::endl; exit(0); } - else + else // check the variables if they are set up properly { processInput(vm); } @@ -111,7 +111,7 @@ std::shared_ptr sdddstCore::ProjectParser::getSimula return sD; } -void sdddstCore::ProjectParser::printLicense() +void sdddstCore::ProjectParser::printLicense() // if used multiple times, should move outside this cpp { std::cout << "SDDDST - Simple Discrete Dislocation Dynamics Toolkit\n" "Copyright (C) 2015-2019 Gábor Péterffy \n" From e5e37a120704679e917787dd1d0ea4c24781772b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20T=C3=BCzes?= Date: Fri, 17 May 2019 17:24:03 +0200 Subject: [PATCH 06/10] dislocations can be sorted, added short option names too --- init_config_gen/README.md | 8 ++--- init_config_gen/init_config_gen.cpp | 55 ++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/init_config_gen/README.md b/init_config_gen/README.md index b9bf6be..6610c4b 100644 --- a/init_config_gen/README.md +++ b/init_config_gen/README.md @@ -16,10 +16,10 @@ Type `2D_DDD_simulation --help` to get the help. The program accepts the followi ## Output The program creates the initial conditions in the folder `dislocation-configurations` relative to the binary, with filenames `init_config_SEEDVALUE.txt`. The file format is as described in [SDSST](https://github.com/danieltuzes/sdddst). The output is a simple text file in the format ``` -pos_1_x pos_1_y burgers_vector_1 -pos_2_x pos_2_y burgers_vector_2 +pos_1_x pos_1_y Burgers_vector_1 +pos_2_x pos_2_y Burgers_vector_2 ... -pos_N_x pos_N_y burgers_vector_N +pos_N_x pos_N_y Burgers_vector_N ``` -with alternating Burger's vector. Please keep in mind that line endings (`CR` and `LF`) will depend on your operating system. \ No newline at end of file +If parameter `sorted` is `true`, then dislocations with positive Burger's vector come first with decreasing y coordinate. If `false` is set, dislocations comes with alternating Burger's vector and random coordinate values. Please keep in mind that line endings (`CR` and `LF`) will depend on your operating system. \ No newline at end of file diff --git a/init_config_gen/init_config_gen.cpp b/init_config_gen/init_config_gen.cpp index 32ace38..31cc1fd 100644 --- a/init_config_gen/init_config_gen.cpp +++ b/init_config_gen/init_config_gen.cpp @@ -8,6 +8,8 @@ #include #include +#include +#include namespace bpo = boost::program_options; namespace br = boost::random; @@ -16,15 +18,17 @@ int main(int argc, char** argv) #pragma region read in variables std::cout << 1 + 1; bpo::options_description requiredOptions("Required options"); // must be set from command line or file - bpo::options_description optionalOptions("Seed options"); // must be set from command line or file + bpo::options_description optionalOptions("Optional options"); // must be set from command line or file requiredOptions.add_options() - ("N", bpo::value(), "The number of dislocations to generate. Must be even, because N/2 number of positive and negative dislocations will be created."); + ("N,N", bpo::value(), "The number of dislocations to generate. Must be even, because N/2 number of positive and negative dislocations will be created."); optionalOptions.add_options() - ("seed-start", bpo::value()->default_value(1000), "An integer used as an initial seed value for the random number generator.") - ("seed-end", bpo::value(), "An integer used as the last seed value for the random number generator, seed-end > seed_start must hold. If set, seed-end - seed-start number of initial configurations will be created.") + ("seed-start,S", bpo::value()->default_value(1000), "An integer used as an initial seed value for the random number generator.") + ("seed-end,E", bpo::value(), "An integer used as the last seed value for the random number generator, seed-end > seed_start must hold. If set, seed-end - seed-start number of initial configurations will be created.") + ("sorted,O", bpo::value()->default_value("true"), "If dislocations should be printed out in order starting with positive Burger's vector and highest value in y.") ; + bool make_sorted; bpo::options_description options; // the superior container of the options @@ -77,17 +81,29 @@ int main(int argc, char** argv) std::cerr << "seed-end > seed-start must hold. Program terminates." << std::endl; exit(-1); } + + // does the user want the results non-sorted? + std::string sorted = vm["sorted"].as(); + if (sorted == "true" || sorted == "1" || sorted == "y") + make_sorted = true; + else if (sorted == "false" || sorted == "0" || sorted == "n") + make_sorted = false; + else + { + std::cerr << "sorted must be either true, 1, y or false, 0, n. Program terminates." << std::endl; + exit(-1); + } } #pragma endregion #pragma region generate and write out configuration - int seed_val = vm["seed-start"].as(); - int seed_end = (vm.count("seed-end") == 0 ? seed_val : vm["seed-end"].as()); - for (;seed_val <= seed_end; ++seed_val) + int seed_val = vm["seed-start"].as(); // the start value read in, or the default value + int seed_end = (vm.count("seed-end") == 0 ? seed_val : vm["seed-end"].as()); // if it is defined by the user, use that value, otherwise, it is = to seed_val + for (;seed_val <= seed_end; ++seed_val) // generate configurations with seeds in the range of [seed-start; seed-end] { - std::string ofname = "dislocation-configurations/init_config_" +std::to_string(seed_val) + ".txt"; - std::ofstream ofile(ofname); - if (!ofile) + std::string ofname = "dislocation-configurations/init_config_" +std::to_string(seed_val) + ".txt"; // output filename; the file is inside a folder + std::ofstream ofile(ofname); // the filestream + if (!ofile) // evaluates to false if file cannot be opened { std::cerr << "Cannot write " << ofname << ". Program terminates." << std::endl; exit(-1); @@ -95,13 +111,18 @@ int main(int argc, char** argv) std::cout << "Generating configuration with seed value " << seed_val << "." << std::endl; ofile.precision(std::numeric_limits::max_digits10); // print out every digits - br::mt19937 generator(seed_val); - br::uniform_real_distribution<> distribution(-0.5, 0.5); - for (int n = 0; n < vm["N"].as(); ++n) - ofile << distribution(generator) - << "\t" << distribution(generator) - << "\t" << (n % 2) * 2 - 1 - << "\n"; + br::mt19937 engine(seed_val); // Mersenne twister is a good and expensive random number generator + br::uniform_real_distribution<> distr(-0.5, 0.5); // uniform distribution on [-0.5; 0.5) + using disl = std::tuple; // a dislocation is a (double, double, int) tuple + std::vector dislocs; // container of the N number of dislocations + + for (int n = 0; n < vm["N"].as(); ++n) // generate the N number of dislocations + dislocs.push_back(disl(distr(engine), distr(engine), (n % 2) * 2 - 1)); // x, y coordinates, and the Burger's vector + + if (make_sorted) // sorting if not told otherwise + std::sort(dislocs.begin(), dislocs.end(), [](const disl& a, const disl& b) {return (std::get<1>(a) + std::get<2>(a)) > (std::get<1>(b) + std::get<2>(b)); }); + + for_each(dislocs.begin(), dislocs.end(), [&ofile](const disl& a) {ofile << std::get<0>(a) << "\t" << std::get<1>(a) << "\t" << std::get<2>(a) << "\n"; }); // print out to ofile } #pragma endregion From ab38f4884e051db776d48964347cfe95d136bc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20T=C3=BCzes?= Date: Fri, 17 May 2019 17:32:09 +0200 Subject: [PATCH 07/10] style improved --- init_config_gen/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init_config_gen/README.md b/init_config_gen/README.md index 6610c4b..69d59a3 100644 --- a/init_config_gen/README.md +++ b/init_config_gen/README.md @@ -22,4 +22,4 @@ pos_2_x pos_2_y Burgers_vector_2 pos_N_x pos_N_y Burgers_vector_N ``` -If parameter `sorted` is `true`, then dislocations with positive Burger's vector come first with decreasing y coordinate. If `false` is set, dislocations comes with alternating Burger's vector and random coordinate values. Please keep in mind that line endings (`CR` and `LF`) will depend on your operating system. \ No newline at end of file +If the default value of parameter `sorted` is kept `true`, then dislocations with positive Burger's vector come first with decreasing y coordinate. If `false` is set, dislocations comes with alternating Burger's vector and random coordinate values. Please keep in mind that line endings (`CR` and `LF`) will depend on your operating system. \ No newline at end of file From 5271cc73e4f9511fad7446df711575790c069284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20T=C3=BCzes?= Date: Fri, 17 May 2019 21:00:37 +0200 Subject: [PATCH 08/10] argument parameters updated --- init_config_gen/README.md | 16 +++++---- init_config_gen/init_config_gen.cpp | 51 +++++++++++++++++++---------- src/project_parser.cpp | 46 +++++++++++++------------- 3 files changed, 65 insertions(+), 48 deletions(-) diff --git a/init_config_gen/README.md b/init_config_gen/README.md index 69d59a3..0c304e3 100644 --- a/init_config_gen/README.md +++ b/init_config_gen/README.md @@ -2,19 +2,21 @@ The initial configuration generator tool for Simple Discrete Dislocation Dynamics Simulation Toolkit ## Short description -With this tool one can create dislocation configurations to use as an input of the simulation program 2D_DDD_simulation. +With this tool one can create dislocation configurations to use as an input of the simulation program 2D_DDD_simulation. It uses a platform independent implementation provided by [`boost.random`](https://www.boost.org/doc/libs/1_70_0/doc/html/boost_random.html). ## Dependencies -There is 1 new dependencie: `boost.random`. To compile this project you need boost's program options and random libraries. The first is already a requirement for the project *2D_DDD_simulation*. +There is 1 new dependency: [`boost.random`](https://www.boost.org/doc/libs/1_70_0/doc/html/boost_random.html). To compile this project you need boost's program options and random libraries. The first is already a requirement for the project *2D_DDD_simulation*. ## Usage -Type `2D_DDD_simulation --help` to get the help. The program accepts the following arguments: -* `--N arg`: mandatory argument. The number of dislocations to simulate. Must be an even number, because the same amount of positive and negative dislocations must be found in the system. -* `--seed-start arg`: optional argument with default value `1000`. It is an integer used to populate the seed value of the random number generator. -* `--seed-end arg`: optional argument. If set, must be larger than `seed_start` and the program will create configuration files starting from seed value `seed-start`, increasing it one by one till it reaches `seed-end` (closed interval). +Type `init_config_gen --help` to get the help. The program accepts the following arguments: +* `--N arg` or `-N arg`: **mandatory** argument. The number of dislocations to simulate. Must be an even number, because the same amount of positive and negative dislocations must be found in the system. +* `--seed-start arg` or `-S arg`: optional argument with default value `1000`. It is an integer used to populate the seed value of the random number generator engine. +* `--seed-end arg` or `-E arg`: optional argument. If set, must be larger than `seed_start` and the program will create configuration files starting from seed value `seed-start`, increasing it one by one till it reaches `seed-end` (closed interval). +* `--unsorted` or `-U`: optional switch. If set, dislocations will not printed out in order starting with positive Burger's vector and highest value in y, but with alternating Burger's vector and uncorrelated x and y coordinates. +* `--bare` or `-B`: optional swtich. If set, the configuration file name will not conatin the number of dislocations. ## Output -The program creates the initial conditions in the folder `dislocation-configurations` relative to the binary, with filenames `init_config_SEEDVALUE.txt`. The file format is as described in [SDSST](https://github.com/danieltuzes/sdddst). The output is a simple text file in the format +The program creates the initial conditions in the folder `dislocation-configurations` relative to the binary, with filenames `ic_SEEDVALUE_N.txt`. The file format is as described in [SDSST](https://github.com/danieltuzes/sdddst). The output is a simple text file in the format ``` pos_1_x pos_1_y Burgers_vector_1 pos_2_x pos_2_y Burgers_vector_2 diff --git a/init_config_gen/init_config_gen.cpp b/init_config_gen/init_config_gen.cpp index 31cc1fd..e76a5b1 100644 --- a/init_config_gen/init_config_gen.cpp +++ b/init_config_gen/init_config_gen.cpp @@ -1,5 +1,25 @@ + // init_config_gen.cpp : This file contains the 'main' function. Program execution begins and ends there. // +/* + * SDDDST Simple Discrete Dislocation Dynamics Toolkit + * Copyright (C) 2015-2019 Gábor Péterffy , Dániel Tüzes and their friends. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #include // to read in program call arguments #include // to add descriptions of the program call arguments @@ -26,9 +46,9 @@ int main(int argc, char** argv) optionalOptions.add_options() ("seed-start,S", bpo::value()->default_value(1000), "An integer used as an initial seed value for the random number generator.") ("seed-end,E", bpo::value(), "An integer used as the last seed value for the random number generator, seed-end > seed_start must hold. If set, seed-end - seed-start number of initial configurations will be created.") - ("sorted,O", bpo::value()->default_value("true"), "If dislocations should be printed out in order starting with positive Burger's vector and highest value in y.") + ("unsorted,U", "If set, dislocations will not printed out in order starting with positive Burger's vector and highest value in y, but with alternating Burger's vector and uncorrelated x and y coordinates.") + ("bare,B", "If set, filenames will not contain the value of the parameter N.") ; - bool make_sorted; bpo::options_description options; // the superior container of the options @@ -78,30 +98,25 @@ int main(int argc, char** argv) // seed-end >? seed-start if (vm.count("seed-end") != 0 && vm["seed-end"].as() <= vm["seed-start"].as()) { - std::cerr << "seed-end > seed-start must hold. Program terminates." << std::endl; + std::cerr << "seed-end >= seed-start must hold. Program terminates." << std::endl; exit(-1); } - - // does the user want the results non-sorted? - std::string sorted = vm["sorted"].as(); - if (sorted == "true" || sorted == "1" || sorted == "y") - make_sorted = true; - else if (sorted == "false" || sorted == "0" || sorted == "n") - make_sorted = false; - else + if (vm.count("seed-end") == 0) // label: seed-end set { - std::cerr << "sorted must be either true, 1, y or false, 0, n. Program terminates." << std::endl; - exit(-1); + vm.insert(std::make_pair("seed-end", bpo::variable_value())); } + vm.at("seed-end").value() = vm["seed-start"].as(); } #pragma endregion #pragma region generate and write out configuration - int seed_val = vm["seed-start"].as(); // the start value read in, or the default value - int seed_end = (vm.count("seed-end") == 0 ? seed_val : vm["seed-end"].as()); // if it is defined by the user, use that value, otherwise, it is = to seed_val - for (;seed_val <= seed_end; ++seed_val) // generate configurations with seeds in the range of [seed-start; seed-end] + for (int seed_val = vm["seed-start"].as(); seed_val <= vm["seed-end"].as(); ++seed_val) // generate configurations with seeds in the range of [seed-start; seed-end]; seed-end has been set at label: seed-end set { - std::string ofname = "dislocation-configurations/init_config_" +std::to_string(seed_val) + ".txt"; // output filename; the file is inside a folder + std::string ofname = "dislocation-configurations/ic_" + std::to_string(seed_val); + if(vm.count("bare") == 0) + ofname += "_" + std::to_string(vm["N"].as()); + ofname += ".txt"; // output filename; the file is inside a folder + std::ofstream ofile(ofname); // the filestream if (!ofile) // evaluates to false if file cannot be opened { @@ -119,7 +134,7 @@ int main(int argc, char** argv) for (int n = 0; n < vm["N"].as(); ++n) // generate the N number of dislocations dislocs.push_back(disl(distr(engine), distr(engine), (n % 2) * 2 - 1)); // x, y coordinates, and the Burger's vector - if (make_sorted) // sorting if not told otherwise + if (vm.count("unsorted") == 0) // sorting if not told otherwise std::sort(dislocs.begin(), dislocs.end(), [](const disl& a, const disl& b) {return (std::get<1>(a) + std::get<2>(a)) > (std::get<1>(b) + std::get<2>(b)); }); for_each(dislocs.begin(), dislocs.end(), [&ofile](const disl& a) {ofile << std::get<0>(a) << "\t" << std::get<1>(a) << "\t" << std::get<2>(a) << "\n"; }); // print out to ofile diff --git a/src/project_parser.cpp b/src/project_parser.cpp index aefaeb0..22ea398 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -35,38 +35,38 @@ sdddstCore::ProjectParser::ProjectParser(int argc, char **argv): boost::program_options::options_description externalStressProtocolOptions("External stress protocols (optional)"); // how the external stress should increase requiredOptions.add_options() - ("dislocation-configuration", boost::program_options::value(), "plain text file path containing dislocation data in {x y b} triplets") - ("result-dislocation-configuration", boost::program_options::value(), "path where the result configuration will be stored at the end of the simulation") + ("dislocation-configuration,I", boost::program_options::value(), "plain text file path containing dislocation data in (x y b) triplets") + ("result-dislocation-configuration,O", boost::program_options::value(), "path where the result configuration will be stored at the end of the simulation") ; optionalOptions.add_options() - ("point-defect-configuration", boost::program_options::value(), "plain text file path containing point defect data in {x y} pairs") - ("logfile-path", boost::program_options::value(), "path for the plain text log file (it will be overwritten if it already exists)") - ("time-limit", boost::program_options::value(), "in simulation time limit, if reached the simulation stops") - ("step-count-limit", boost::program_options::value(), "the simulation will stop after successful N steps") - ("strain-increase-limit", boost::program_options::value(), "the simulation will stop after arg total strain increase is reached") - ("avalanche-detection-limit", boost::program_options::value(), "the simulation will stop after the threshold was reached with the given numer of events from above") - ("avalanche-speed-threshold", boost::program_options::value()->default_value(1e-3), "speed threshold for counting avalanches") - ("initial-stepsize", boost::program_options::value()->default_value(1e-6), "first tried step size for the simulation") - ("cutoff-multiplier", boost::program_options::value()->default_value(1e20), "multiplier of the 1/sqrt(N) cutoff parameter") - ("max-stepsize", boost::program_options::value(), "the stepsize can not overleap this value") - ("calculate-strain", "turns on strain calculation for the simulation") - ("calculate-order-parameter", "turns on order parameter calculation during the simulation") - ("position-precision", boost::program_options::value()->default_value(1e-5), "minimum precision for the positions for the adaptive step size protocol") - ("save-sub-configurations", boost::program_options::value(), "saves the current configuration after every N successful step to the given destination") - ("sub-configuration-delay", boost::program_options::value()->default_value(5), "number of successful steps between the sub configurations written out") - ("sub-configuration-delay-during-avalanche", boost::program_options::value()->default_value(1), "number of successful steps between the sub configurations written out during avalanche if avalanche detection is on") + ("point-defect-configuration,PI", boost::program_options::value(), "plain text file path containing point defect data in (x y) pairs") + ("logfile-path,L", boost::program_options::value(), "path for the plain text log file (it will be overwritten if it already exists)") + ("time-limit,TL", boost::program_options::value(), "the simulation stops if simulation time reached this limit") + ("step-count-limit,SCL", boost::program_options::value(), "the simulation will stop after successful N=SCL steps") + ("strain-increase-limit,SIL", boost::program_options::value(), "the simulation will stop after arg total strain increase is reached") + ("avalanche-detection-limit,ADL", boost::program_options::value(), "the simulation will stop after the threshold was reached with the given numer of events from above") + ("avalanche-speed-threshold,AST", boost::program_options::value()->default_value(1e-3), "speed threshold for counting avalanches") + ("initial-stepsize,IS", boost::program_options::value()->default_value(1e-6), "first tried step size for the simulation") + ("cutoff-multiplier,CM", boost::program_options::value()->default_value(1e20), "multiplier of the 1/sqrt(N) cutoff parameter") + ("max-stepsize,MS", boost::program_options::value(), "the stepsize can not overleap this value") + ("calculate-strain,CS", "turns on strain calculation for the simulation") + ("calculate-order-parameter,COP", "turns on order parameter calculation during the simulation") + ("position-precision,PP", boost::program_options::value()->default_value(1e-5), "minimum precision for the positions for the adaptive step size protocol") + ("save-sub-configurations,SSC", boost::program_options::value(), "saves the current configuration after every N=SCD successful step to the given destination") + ("sub-configuration-delay,SCD", boost::program_options::value()->default_value(5), "number of successful steps between the sub configurations written out") + ("sub-configuration-delay-during-avalanche,SDD", boost::program_options::value()->default_value(1), "number of successful steps between the sub configurations written out during avalanche if avalanche detection is on") ; fieldOptions.add_options() - ("periodic-stress-field-elte", boost::program_options::value()->default_value("."), "periodic stress field based on ELTE library, the argument should be the folder where the compressed numerical data can be found (default)") - ("periodic-stress-field-analytic", ("analytic periodic stress field, number of images in each direction: " + std::to_string(ANALYTIC_FIELD_N)).c_str()) + ("periodic-stress-field-elte,SFE", boost::program_options::value()->default_value("."), "periodic stress field based on ELTE library, the argument should be the folder where the compressed numerical data can be found (default)") + ("periodic-stress-field-analytic,SFA", ("analytic periodic stress field, number of images in each direction: " + std::to_string(ANALYTIC_FIELD_N)).c_str()) ; externalStressProtocolOptions.add_options() - ("no-external-stress", "no external stress during the simulation (default)") - ("fixed-rate-external-stress", boost::program_options::value(), "external stress is linear with time, rate should be specified as an arg") - ("spring-constant", boost::program_options::value(), "simple model of an experiment where a spring is used, the arg should be the spring constant (it is valid only with the previous option together)") + ("no-external-stress,NES", "no external stress during the simulation (default)") + ("fixed-rate-external-stress,FES", boost::program_options::value(), "external stress is linear with time, rate should be specified as an arg") + ("spring-constant,SC", boost::program_options::value(), "simple model of an experiment where a spring is used, the arg should be the spring constant (it is valid only with the previous option together)") ; boost::program_options::options_description options; From 07b42c9196fbe09a2886751a02f37aaba59feaf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=BCzes=20D=C3=A1niel?= Date: Sat, 18 May 2019 21:01:19 +0200 Subject: [PATCH 09/10] .gitignored removed, short program options are corrected --- .gitignore | 340 ----------------------------------------- src/project_parser.cpp | 62 ++++---- 2 files changed, 31 insertions(+), 371 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 4ce6fdd..0000000 --- a/.gitignore +++ /dev/null @@ -1,340 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- Backup*.rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb \ No newline at end of file diff --git a/src/project_parser.cpp b/src/project_parser.cpp index 22ea398..6ea4679 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -26,7 +26,7 @@ #include -sdddstCore::ProjectParser::ProjectParser(int argc, char **argv): +sdddstCore::ProjectParser::ProjectParser(int argc, char** argv) : sD(nullptr) { boost::program_options::options_description requiredOptions("Required Options"); // must be set from command line or file @@ -40,33 +40,33 @@ sdddstCore::ProjectParser::ProjectParser(int argc, char **argv): ; optionalOptions.add_options() - ("point-defect-configuration,PI", boost::program_options::value(), "plain text file path containing point defect data in (x y) pairs") + ("point-defect-configuration", boost::program_options::value(), "plain text file path containing point defect data in (x y) pairs") ("logfile-path,L", boost::program_options::value(), "path for the plain text log file (it will be overwritten if it already exists)") - ("time-limit,TL", boost::program_options::value(), "the simulation stops if simulation time reached this limit") - ("step-count-limit,SCL", boost::program_options::value(), "the simulation will stop after successful N=SCL steps") - ("strain-increase-limit,SIL", boost::program_options::value(), "the simulation will stop after arg total strain increase is reached") - ("avalanche-detection-limit,ADL", boost::program_options::value(), "the simulation will stop after the threshold was reached with the given numer of events from above") - ("avalanche-speed-threshold,AST", boost::program_options::value()->default_value(1e-3), "speed threshold for counting avalanches") - ("initial-stepsize,IS", boost::program_options::value()->default_value(1e-6), "first tried step size for the simulation") - ("cutoff-multiplier,CM", boost::program_options::value()->default_value(1e20), "multiplier of the 1/sqrt(N) cutoff parameter") - ("max-stepsize,MS", boost::program_options::value(), "the stepsize can not overleap this value") - ("calculate-strain,CS", "turns on strain calculation for the simulation") - ("calculate-order-parameter,COP", "turns on order parameter calculation during the simulation") - ("position-precision,PP", boost::program_options::value()->default_value(1e-5), "minimum precision for the positions for the adaptive step size protocol") - ("save-sub-configurations,SSC", boost::program_options::value(), "saves the current configuration after every N=SCD successful step to the given destination") - ("sub-configuration-delay,SCD", boost::program_options::value()->default_value(5), "number of successful steps between the sub configurations written out") - ("sub-configuration-delay-during-avalanche,SDD", boost::program_options::value()->default_value(1), "number of successful steps between the sub configurations written out during avalanche if avalanche detection is on") + ("time-limit,t", boost::program_options::value(), "the simulation stops if simulation time reached this limit") + ("step-count-limit,C", boost::program_options::value(), "the simulation will stop after successful N=SCL steps") + ("strain-increase-limit", boost::program_options::value(), "the simulation will stop after arg total strain increase is reached") + ("avalanche-detection-limit", boost::program_options::value(), "the simulation will stop after the threshold was reached with the given numer of events from above") + ("avalanche-speed-threshold", boost::program_options::value()->default_value(1e-3), "speed threshold for counting avalanches") + ("initial-stepsize", boost::program_options::value()->default_value(1e-6), "first tried step size for the simulation") + ("cutoff-multiplier,c", boost::program_options::value()->default_value(1e20), "multiplier of the 1/sqrt(N) cutoff parameter") + ("max-stepsize,M", boost::program_options::value(), "the stepsize can not overleap this value") + ("calculate-strain,S", "turns on strain calculation for the simulation") + ("calculate-order-parameter,l", "turns on order parameter calculation during the simulation") + ("position-precision,P", boost::program_options::value()->default_value(1e-5), "minimum precision for the positions for the adaptive step size protocol") + ("save-sub-configurations,o", boost::program_options::value(), "saves the current configuration after every N=SCD successful step to the given destination") + ("sub-configuration-delay,N", boost::program_options::value()->default_value(5), "number of successful steps between the sub configurations written out") + ("sub-configuration-delay-during-avalanche,n", boost::program_options::value()->default_value(1), "number of successful steps between the sub configurations written out during avalanche if avalanche detection is on") ; fieldOptions.add_options() - ("periodic-stress-field-elte,SFE", boost::program_options::value()->default_value("."), "periodic stress field based on ELTE library, the argument should be the folder where the compressed numerical data can be found (default)") - ("periodic-stress-field-analytic,SFA", ("analytic periodic stress field, number of images in each direction: " + std::to_string(ANALYTIC_FIELD_N)).c_str()) + ("periodic-stress-field-elte,p", boost::program_options::value()->default_value("."), "periodic stress field based on ELTE library, the argument should be the folder where the compressed numerical data can be found (default)") + ("periodic-stress-field-analytic,m", ("analytic periodic stress field, number of images in each direction: " + std::to_string(ANALYTIC_FIELD_N)).c_str()) ; externalStressProtocolOptions.add_options() - ("no-external-stress,NES", "no external stress during the simulation (default)") - ("fixed-rate-external-stress,FES", boost::program_options::value(), "external stress is linear with time, rate should be specified as an arg") - ("spring-constant,SC", boost::program_options::value(), "simple model of an experiment where a spring is used, the arg should be the spring constant (it is valid only with the previous option together)") + ("no-external-stress,s", "no external stress during the simulation (default)") + ("fixed-rate-external-stress,f", boost::program_options::value(), "external stress is linear with time, rate should be specified as an arg") + ("spring-constant", boost::program_options::value(), "simple model of an experiment where a spring is used, the arg should be the spring constant (it is valid only with the previous option together)") ; boost::program_options::options_description options; @@ -114,11 +114,11 @@ std::shared_ptr sdddstCore::ProjectParser::getSimula void sdddstCore::ProjectParser::printLicense() // if used multiple times, should move outside this cpp { std::cout << "SDDDST - Simple Discrete Dislocation Dynamics Toolkit\n" - "Copyright (C) 2015-2019 Gábor Péterffy \n" - "This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions; see the license for details\n"; + "Copyright (C) 2015-2019 Gábor Péterffy \n" + "This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions; see the license for details\n"; } -void sdddstCore::ProjectParser::processInput(boost::program_options::variables_map &vm) +void sdddstCore::ProjectParser::processInput(boost::program_options::variables_map & vm) { // Check for required options if (0 == vm.count("dislocation-configuration")) @@ -136,7 +136,7 @@ void sdddstCore::ProjectParser::processInput(boost::program_options::variables_m if (vm.count("point-defect-configuration") == 1) { sD = std::shared_ptr(new SimulationData(vm["dislocation-configuration"].as(), - vm["point-defect-configuration"].as())); + vm["point-defect-configuration"].as())); } else { @@ -178,7 +178,7 @@ void sdddstCore::ProjectParser::processInput(boost::program_options::variables_m if (vm.count("point-defect-configuration")) { - sD->A *= 1./sqrt(sD->dc); + sD->A *= 1. / sqrt(sD->dc); sD->KASQR *= double(sD->dc); } @@ -231,12 +231,12 @@ void sdddstCore::ProjectParser::processInput(boost::program_options::variables_m tmp->loadStress(vm["periodic-stress-field-elte"].as(), "xy_diff_x", 1024); sD->tau = std::move(tmp); } - /* - "no-external-stress", "no external stress during the simulation (default)") - ("fixed-rate-external-stress", boost::program_options::value(), "external stress is linear with time, rate should be specified as an arg") - ("spring-constant" + /* + "no-external-stress", "no external stress during the simulation (default)") + ("fixed-rate-external-stress", boost::program_options::value(), "external stress is linear with time, rate should be specified as an arg") + ("spring-constant" - ;*/ + ;*/ if (vm.count("no-external-stress") && vm.count("fixed-rate-external-stress")) { std::cerr << "Only one stress protocol can be defined at the same time!\n"; From a89b6b1874b2e20515043848451275e86c58d464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=BCzes=20D=C3=A1niel?= Date: Sat, 8 Jun 2019 19:35:43 +0200 Subject: [PATCH 10/10] UTF8, compatibility and short notations --- init_config_gen/init_config_gen.cpp | 22 ++-------------------- src/Fields/PeriodicShearStressELTE.cpp | 4 ++-- src/project_parser.cpp | 4 ++-- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/init_config_gen/init_config_gen.cpp b/init_config_gen/init_config_gen.cpp index e76a5b1..9825d21 100644 --- a/init_config_gen/init_config_gen.cpp +++ b/init_config_gen/init_config_gen.cpp @@ -1,24 +1,6 @@ // init_config_gen.cpp : This file contains the 'main' function. Program execution begins and ends there. -// -/* - * SDDDST Simple Discrete Dislocation Dynamics Toolkit - * Copyright (C) 2015-2019 Gábor Péterffy , Dániel Tüzes and their friends. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ + #include // to read in program call arguments @@ -70,7 +52,7 @@ int main(int argc, char** argv) if (!vm.count("hide-copyright")) { std::cout << "init_config_gen from the SDDDST - Simple Discrete Dislocation Dynamics Toolkit\n" - "Copyright (C) 2015-2019 Gabor Peterffy , Daniel Tuzes and their friends.\n" + "Copyright (C) 2015-2019 Gábor Péterffy , Dániel Tüzes and their friends.\n" "This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions; see the license for details\n"; } #pragma endregion diff --git a/src/Fields/PeriodicShearStressELTE.cpp b/src/Fields/PeriodicShearStressELTE.cpp index 55c4600..44843a0 100644 --- a/src/Fields/PeriodicShearStressELTE.cpp +++ b/src/Fields/PeriodicShearStressELTE.cpp @@ -1,6 +1,6 @@ /* * SDDDST Simple Discrete Dislocation Dynamics Toolkit - * Copyright (C) 2015-2019 Gábor Péterffy + * Copyright (C) 2015-2019 Gábor Péterffy , Dániel Tüzes and their friends. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -121,7 +121,7 @@ void PeriodicShearStressELTE::loadStress(std::string path, const char *str, int for(unsigned int i=0; i + * Copyright (C) 2015-2019 Gábor Péterffy , Dániel Tüzes and their friends. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,7 +55,7 @@ sdddstCore::ProjectParser::ProjectParser(int argc, char** argv) : ("position-precision,P", boost::program_options::value()->default_value(1e-5), "minimum precision for the positions for the adaptive step size protocol") ("save-sub-configurations,o", boost::program_options::value(), "saves the current configuration after every N=SCD successful step to the given destination") ("sub-configuration-delay,N", boost::program_options::value()->default_value(5), "number of successful steps between the sub configurations written out") - ("sub-configuration-delay-during-avalanche,n", boost::program_options::value()->default_value(1), "number of successful steps between the sub configurations written out during avalanche if avalanche detection is on") + ("sub-configuration-delay-during-avalanche,n", boost::program_options::value()->default_value(1), "number of successful steps between the sub configurations written out during avalanche if avalanche detection is on") ; fieldOptions.add_options()