subConfigStart = Config() subConfigStart.readFile(defaultConfigFilePath) oldSaveFile = subConfigStart.value("simulation.saveFileName")[0] newSaveFile = oldSaveFile.replace("$DATEDIR", "$DATEDIR/" + runName) subConfigStart.setValue("simulation.saveFileName", newSaveFile) subConfigStart.setValue("initialization.[1].initialTemperature", temperature) subConfigStart.setValue("modifiers.[0].targetTemperature", temperature) subConfigStart.writeFile(subConfigFilePath) subConfigEnd = Config() subConfigEnd.readFile(defaultEndConfigFilePath) oldSaveFile = subConfigEnd.value("simulation.saveFileName")[0] newSaveFile = oldSaveFile.replace("$DATEDIR", "$DATEDIR/" + runName) subConfigEnd.setValue("simulation.saveFileName", newSaveFile) oldLoadFile = subConfigEnd.value("initialization.[0].fileName")[0] newLoadFile = oldLoadFile.replace("$DATEDIR", "$DATEDIR/" + runName) subConfigEnd.setValue("initialization.[0].fileName", newLoadFile) subConfigEnd.writeFile(subConfigEndFilePath) stepConfig = Config() stepConfig.addGroup("", "runConfig") stepConfig.addList("runConfig", "subConfigs") stepConfigFileName = join(defaultConfigDir, runName, runName + ".cfg") stepConfig.appendToList("runConfig.subConfigs", split(subConfigFileName)[1]) stepConfig.appendToList("runConfig.subConfigs", split(subConfigEndFileName)[1]) stepConfig.writeFile(stepConfigFileName) config.appendToList("runConfig.subConfigs", join(runName, runName + ".cfg")) iRun += 1 config.writeFile(join(defaultConfigDir, "temperatures.cfg"))
from sys import argv from os.path import split, join from fys4460 import makedirsSilent defaultConfigFilePath = "1k-temperature/default.cfg" defaultConfigDir, defaultConfigFileName = split(defaultConfigFilePath) systemSizes = [6, 7, 8, 9, 10, 11, 12] config = Config() config.addGroup("", "runConfig") config.addList("runConfig", "subConfigs") iRun = 0 for systemSize in systemSizes: runName = "systemsize%04d" % systemSize subConfigFileName = join(runName, runName + ".cfg") subConfigFilePath = join(defaultConfigDir, subConfigFileName) print split(subConfigFilePath)[0] makedirsSilent(split(subConfigFilePath)[0]) subConfig = Config() subConfig.readFile(defaultConfigFilePath) subConfig.setValue("initialization.[0].nCells", systemSize) saveFileName = subConfig.value("simulation.saveFileName")[0] saveFileName = saveFileName.replace("$DATEDIR", "$DATEDIR/" + runName) subConfig.setValue("simulation.saveFileName", saveFileName) subConfig.writeFile(subConfigFilePath) config.appendToList("runConfig.subConfigs", subConfigFileName) iRun += 1 config.writeFile(join(defaultConfigDir, "systemsizes.cfg"))