ParallelCycles.FixedIndependentVariableValues = (
    NonCO2CycleFixedIndependentVariableValues,
    CO2CycleFixedIndependentVariableValues)

#note, IndependentVariableValues is used here to maintain compatibility with the brute force mode, which has everything sent to this variable.
#also note, ReplicateCombinedCycleInputs is done later for this variable in order to reduce unnecessary sweep permutations
ParallelCycles.IndependentVariableValues = NonCO2CycleSweptIndependentVariableValues + CO2CycleSweptIndependentVariableValues

ParallelCycles.IndependentVariableLabels = IndependentVariableLabels
ParallelCycles.NonCO2CycleIndependentVariableLabels = NonCO2CycleIndependentVariableLabels
ParallelCycles.IndependentVariableMappings = IndependentVariableMappings
ParallelCycles.NonCO2CycleIndependentVariableMappings = NonCO2CycleIndependentVariableMappings

ParallelCycles.ValueCount = (
    MaxNumberOfEngines, len(NonCO2CycleInitialGuessIndependentVariableValues),
    len(NonCO2CycleFixedIndependentVariableValues),
    len(NonCO2CycleSweptIndependentVariableValues))

ParallelCycles.PrintOutputs = PrintExtra  #think this may have been changed to helpers.PrintWarningMessages, so it is obsolete???
ParallelCycles.NumberOfCPUs = 2  #note, setting this to 1 will not use joblib. if raising errors for debugging, seem to need to use 1 because joblib gives weird errors when a permutation has an exception. note error make more sense now that joblib was updated to a new version, but still need to set to serial mode to actually debug them.
ParallelCycles.RunName = helpers.GetCaseName()

#save out a few extra objects needed for post processing
WriteAdditionalObjects(ParallelCycles.FixedIndependentVariableValues,
                       NonCO2CycleIndependentVariableLabels,
                       ParallelCycles.ValueCount)

#optimize based on initial guesses and fixed values and swept values
Results = RunParameterSweepPermutations(
    ParameterSweepAndOptimizeCombinedCycleWrapper)
Exemplo n.º 2
0
SweptIndependentVariableValues += (linspace(1, 4, num=20), )
IndependentVariableLabels += ('PreCompressor Pressure Ratio', )
IndependentVariableMappings += (
    "CycleInputParameters['PreCompressor']['PressureRatio']", )

SweptIndependentVariableValues += (linspace(1.1, 4.1, num=20), )
IndependentVariableLabels += ('Main Compressor Pressure Ratio', )
IndependentVariableMappings += (
    "CycleInputParameters['MainCompressor']['PressureRatio']", )

####################################################

#assign some values so that when Optimize is run, they can be inherited and used
ParallelCycles.IndependentVariableMappings = IndependentVariableMappings
ParallelCycles.IndependentVariableLabels = IndependentVariableLabels
ParallelCycles.IndependentVariableValueLimits = IndependentVariableValueLimits
ParallelCycles.InitialGuessIndependentVariableValues = InitialGuessIndependentVariableValues
ParallelCycles.FixedIndependentVariableValues = FixedIndependentVariableValues
ParallelCycles.IndependentVariableValues = SweptIndependentVariableValues  #note, IndependentVariableValues is used here to maintain compatibility with the brute force mode, which has everything sent to this variable

#optimize based on initial guesses and fixed values

ParallelCycles.PrintOutputs = False  #think this may have been changed to helpers.PrintWarningMessages, so it is obsolete???
ParallelCycles.NumberOfCPUs = 2  #note, setting this to 1 will not use joblib. if raising errors for debugging, seem to need to use 1 because joblib gives weird errors when a permutation has an exception. note error make more sense now that joblib was updated to a new version, but still need to set to serial mode to actually debug them.
ParallelCycles.RunName = helpers.GetCaseName()

#save out a few extra objects needed for post processing
WriteAdditionalObjects(FixedIndependentVariableValues, None, None)

Results = RunParameterSweepPermutations(ParameterSweepAndOptimizeCycleWrapper)
ParallelCycles.IndependentVariableValueLimits = IndependentVariableValueLimits  #only needed if CombinedOptimization=False?
ParallelCycles.IndependentVariableLabels = IndependentVariableLabels
ParallelCycles.NonCO2CycleIndependentVariableLabels = NonCO2CycleIndependentVariableLabels
ParallelCycles.IndependentVariableMappings = IndependentVariableMappings
ParallelCycles.NonCO2CycleIndependentVariableMappings = NonCO2CycleIndependentVariableMappings

ValueCount = (NumberOfEngines,
              len(NonCO2CycleInitialGuessIndependentVariableValues),
              len(NonCO2CycleFixedIndependentVariableValues), 0)

#optimize based on initial guesses and fixed values

ParallelCycles.PrintOutputs = PrintExtra  #think this may have been changed to helpers.PrintWarningMessages, so it is obsolete???

ParallelCycles.RunName = helpers.GetCaseName()

#save out a few extra objects needed for post processing
WriteAdditionalObjects((NonCO2CycleFixedIndependentVariableValues,
                        CO2CycleFixedIndependentVariableValues),
                       NonCO2CycleIndependentVariableLabels, ValueCount)

#run the optimization
CombinedCycleEfficiency, AllEnginesOptimizedIndependentVariableValues = OptimizeCombinedCycle(
    AllEnginesInitialGuessIndependentVariableValues,
    AllEnginesFixedIndependentVariableValues, ValueCount, LineColors,
    CombinedOptimization, AllEnginesIndependentVariableValueLimits
)  #save AllEnginesInitialGuessIndependentVariableValues so it can be passed back later to get a better initial condition

WriteResultObject((CombinedCycleEfficiency, ) +
                  AllEnginesOptimizedIndependentVariableValues)