Redesign userinput
-
Set default values for all fields (if there is really no good default for some fields, make them mandatory). -
Remove Suffix _i
from all fields -
Rename userinput
->UserInput
orUserinput
(Naming conventions). Also apply naming conventions to all fields. -
Make the class a data only struct without constructor. Benefit: Can now do direct initialization const auto userinput = UserInput{ .N_zones = 1, .constrained_direction = 1, ... };
-
Move readParametersXMLFile
out of theclass
/struct
, replacing it withUserInput load_user_input(const std::filesystem::path &path)
-
Use
std::optional
instead of boolean flag, value pairs wherever possible-
read_restart
andrestart_file_name
can be combined -
Drop those unused fieldssave_restart_files
andrestart_files_frequency
can be combined -
save_output_files
andoutput_files_frequency
can be combined -
Drop fieldonsager_coefficient
,dt_transport_coeff
andheat_rate_tolerance_per_atom
are used only ifthermal_transport_flag
istrue
thermal_transport_flag
-
UseOpenKIM
andModelName
can be combined -
MEAMPotential
,MEAMLibraryFile
andMEAMParameterFile
can be combined -
mid_FIRE_output_flag
andmid_FIRE_output_frequency
can be combined -
we can combine periodic
,minimum
,period_length
andconstrain_periodic_relaxation
-
-
Use std::filesystem::path
for paths -
Make userinput a cmake module -
Warn about invalid field names in input file -
Change type of external_displacement_gradient_i
fromstd::array<double, 9>
->std::array<std::array<double, 3>, 3>
-
replace xml by json. New file would look like: { "DomainAndMeshGeneration": { "x_char": 1.7649832125, "N_zones": 0 }, "SolverTolerances": { "MaxForceResiduePerAtom": 1.0e-6, "MaxThermalForceResiduePerAtom": 1.0e-6, "MaxPeriodicForceResiduePerAtom": 1.0e-6 }, "SimulationSettings": { ... "X periodic": true, ... "fixed_box_upper": [125.0, 13.264, 40.0], ... }, ... }
Compared to xml:
<UserInputParameters Version="0.1"> <DomainAndMeshGeneration> <Fields> <Field Name="x_char"> 1.7649832125 </Field> <Field Name="N_zones"> 0 </Field> </Fields> </DomainAndMeshGeneration> <SolverTolerances> <Fields> <Field Name="MaxForceResiduePerAtom"> 1.0e-6 </Field> <Field Name="MaxThermalForceResiduePerAtom"> 1.0e-6 </Field> <Field Name="MaxPeriodicForceResiduePerAtom"> 1.0e-6 </Field> </Fields> </SolverTolerances> <SimulationSettings> <Fields> ... <Field Name="X periodic"> true</Field> ... <Field Name="fixed_box_upper"> 125.0, 13.264, 40.0 </Field> ... </Fields> </SimulationSettings> ... </UserInputParameters>
Benefits:
- support for lists
[]
,true
,false
,null
(<->std::optional
) supported by the format. - Compacter files
- json is more lightweight than xml -> less complex parsing using nlohmann_json
- support for lists
-
write a JSON schema that helps with editing, and we could also use it to check the JSON -
Provide an xml -> json converter to make migration smooth
Open tasks: