Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

**Kratos version:** 8.1

**XMC version:** 2.0
**XMC version:** Kratos default version

**PyCOMPSs version:** 2.7
**PyCOMPSs version:** Kratos default version to run in serial, >2.8 to run with `runcompss`

**Source files:** [Asynchronous Monte Carlo and Asynchronous Multilevel Monte Carlo](source)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"properties" : [{
"model_part_name" : "model",
"properties_id" : 1,
"Material" : {
"Variables" : {
"DENSITY" : 1.225
},
"Tables" : {}
}
}]
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"input_type" : "mdpa",
"input_filename" : "problem_settings/naca0012Mesh4"
},
"material_import_settings": {
"materials_filename": "problem_settings/materials.json"
},
"formulation" : {
"element_type": "compressible"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"input_type" : "mdpa",
"input_filename" : "problem_settings/CPS_MONTECARLO_MeshInterpError1e-2"
},
"material_import_settings": {
"materials_filename": "problem_settings/materials.json"
},
"formulation" : {
"element_type": "compressible"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"input_type" : "mdpa",
"input_filename" : "problem_settings/CPS_MONTECARLO_MeshInterpError5e-3"
},
"material_import_settings": {
"materials_filename": "problem_settings/materials.json"
},
"formulation" : {
"element_type": "compressible"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"hessian_metric": {
"metric": {
"hessian_strategy_parameters" :{
"metric_variable" : ["VELOCITY_X,VELOCITY_Y"],
"estimate_interpolation_error" : false,
Expand All @@ -11,7 +11,7 @@
"anisotropy_remeshing" : true,
"enforce_anisotropy_relative_variable" : false
},
"refinement_mmg" : {
"remeshing" : {
"initialize_entities" : false,
"echo_level" : 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
"tolerancesForHierarchy": [0],
"positionMaxNumberIterationsCriterion": 2
},
"costEstimatorInputDictionary": {
"indexSetDimension": 0,
"order": 1
},
"hierarchyOptimiserInputDictionary": {
"defaultHierarchy": [[[],5]],
"indexSpace": [1,1],
Expand All @@ -20,9 +16,17 @@
},
"monteCarloIndexInputDictionary": {
"costEstimator": "xmc.momentEstimator.MomentEstimator",
"costEstimatorInputDictionary": {
"indexSetDimension": 0, "order": 1, "updatedPowerSums":"xmc.methodDefs_momentEstimator.updatePowerSums.updatePowerSumsOrder2Dimension0", "centralMomentComputer":"xmc.methodDefs_momentEstimator.computeCentralMoments.centralMomentWrapper", "centralMomentErrorComputer":"xmc.methodDefs_momentEstimator.computeErrorEstimation.centralMomentErrorWrapper"
},
"indexValue": null,
"qoiEstimator": ["xmc.momentEstimator.MomentEstimator"],
"combinedEstimator": ["xmc.momentEstimator.CombinedMomentEstimator"],
"qoiEstimator": [
"xmc.momentEstimator.MomentEstimator",
"xmc.momentEstimator.MultiMomentEstimator"
],
"qoiEstimatorInputDictionary": [
{"indexSetDimension": 0,"order": 5,"updatedPowerSums":"xmc.methodDefs_momentEstimator.updatePowerSums.updatePowerSumsOrder10Dimension0","centralMomentComputer":"xmc.methodDefs_momentEstimator.computeCentralMoments.centralMomentWrapper","centralMomentErrorComputer":"xmc.methodDefs_momentEstimator.computeErrorEstimation.centralMomentErrorWrapper"},
{"variableDimension": 3432,"order": 1, "isEstimationParallel": false}],
"sampler": "xmc.sampleGenerator.SampleGenerator",
"eventGroupSize": 5
},
Expand All @@ -36,14 +40,6 @@
"qoiPredictor": [],
"initialNumberBatches": 1
},
"qoiEstimatorInputDictionary": {
"indexSetDimension": 0,
"order": 5
},
"combinedEstimatorInputDictionary": {
"indexSetDimension": 0,
"order": 5
},
"randomGeneratorInputDictionary": {
"generator": "xmc.methodDefs_randomGeneratorWrapper.generator.returnUniformAndTwoNormal",
"parameters": [0,4294967295,0.3,0.003,-0.035,0.00035]
Expand All @@ -55,36 +51,35 @@
},
"solverWrapperInputDictionary": {
"adaptiveRefinementJumpToFinestLevel": false,
"analysisStage": "simulation_definition.SimulationScenario",
"asynchronous": true,
"fakeRandomVariable": [0,0.3,0.0],
"index": [],
"mappingOutputQuantities": false,
"numberContributionsPerInstance": 1,
"numberQoI": 3433,
"numberCombinedQoi": 0,
"outputBatchSize": 1717,
"outputBatchSize": 1,
"parameters": null,
"printToFile": true,
"problemId": "problem_airfoil",
"projectParametersPath": "problem_settings/parameters_potential_naca_lev2.json",
"refinementParametersPath": "problem_settings/parameters_refinement.json",
"refinementStrategy": "stochastic_adaptive_refinement",
"sizeMultiXMomentEstimator": 3432,
"taskAllAtOnce": true
},
"monoCriteriaInpuctDictionary" :{
"statisticalError": {
"criteria": "xmc.methodDefs_monoCriterion.criterionFunctions.isLowerThanOrEqualTo",
"tolerance": [0.01],
"tolerance": 0.01,
"input": "error0"
},
"minNumberIterations": {
"criteria": "xmc.methodDefs_monoCriterion.criterionFunctions.isGreaterThanOrEqualTo",
"tolerance": [0],
"tolerance": 0.0,
"input": "algorithmCost"
},
"maxNumberIterations": {
"criteria": "xmc.methodDefs_monoCriterion.criterionFunctions.isGreaterThanOrEqualTo",
"tolerance": [0],
"tolerance": 0.0,
"input": "algorithmCost"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
"tolerancesForHierarchy": [0],
"positionMaxNumberIterationsCriterion": 2
},
"costEstimatorInputDictionary": {
"indexSetDimension": 0,
"order": 1
},
"hierarchyOptimiserInputDictionary": {
"defaultHierarchy": [[[0],5],[[1],5],[[2],5]],
"indexSpace": [10],
Expand All @@ -19,10 +15,23 @@
"toleranceSplittingBounds": [0.5,0.5]
},
"monteCarloIndexInputDictionary": {
"combinedEstimator": ["xmc.momentEstimator.CombinedMomentEstimator"],
"costEstimator": "xmc.momentEstimator.MomentEstimator",
"costEstimatorInputDictionary": {
"indexSetDimension": 0,
"order": 1,
"updatedPowerSums":"xmc.methodDefs_momentEstimator.updatePowerSums.updatePowerSumsOrder2Dimension0",
"centralMomentComputer":"xmc.methodDefs_momentEstimator.computeCentralMoments.centralMomentWrapper",
"centralMomentErrorComputer":"xmc.methodDefs_momentEstimator.computeErrorEstimation.centralMomentErrorWrapper"
},
"indexValue": null,
"qoiEstimator": ["xmc.momentEstimator.MomentEstimator"],
"qoiEstimator": [
"xmc.momentEstimator.MomentEstimator",
"xmc.momentEstimator.MultiMomentEstimator"
],
"qoiEstimatorInputDictionary": [
{"indexSetDimension": 1,"order": 1,"updatedPowerSums":"xmc.methodDefs_momentEstimator.updatePowerSums.updatePowerSumsOrder2Dimension1","centralMomentComputer":"xmc.methodDefs_momentEstimator.computeCentralMoments.centralMomentWrapper","centralMomentErrorComputer":"xmc.methodDefs_momentEstimator.computeErrorEstimation.centralMomentErrorWrapper"},
{"variableDimension": 204,"order": 1, "isEstimationParallel": false}
],
"sampler": "xmc.sampleGenerator.SampleGenerator",
"eventGroupSize": 5
},
Expand All @@ -36,14 +45,6 @@
"qoiPredictor": [],
"initialNumberBatches": 1
},
"qoiEstimatorInputDictionary": {
"indexSetDimension": 1,
"order": 1
},
"combinedEstimatorInputDictionary": {
"indexSetDimension": 1,
"order": 1
},
"randomGeneratorInputDictionary": {
"generator": "xmc.methodDefs_randomGeneratorWrapper.generator.returnUniformAndTwoNormal",
"parameters": [0,4294967295,0.3,0.03,0.0,0.0087]
Expand All @@ -55,36 +56,35 @@
},
"solverWrapperInputDictionary": {
"adaptiveRefinementJumpToFinestLevel": false,
"analysisStage": "simulation_definition.SimulationScenario",
"asynchronous": true,
"fakeRandomVariable": [0,0.3,0.0],
"index": [],
"mappingOutputQuantities": true,
"numberContributionsPerInstance": 1,
"numberQoI": 205,
"numberCombinedQoi": 0,
"outputBatchSize": 1,
"parameters": null,
"printToFile": false,
"problemId": "problem_airfoil",
"projectParametersPath": ["problem_settings/parameters_potential_naca_lev0.json","problem_settings/parameters_potential_naca_lev1.json","problem_settings/parameters_potential_naca_lev2.json"],
"refinementParametersPath": "problem_settings/parameters_refinement.json",
"refinementStrategy": "reading_from_file",
"sizeMultiXMomentEstimator": 204,
"taskAllAtOnce": true
},
"monoCriteriaInpuctDict" :{
"statisticalError": {
"criteria": "xmc.methodDefs_monoCriterion.criterionFunctions.isLowerThanOrEqualTo",
"tolerance": [0.15],
"tolerance": 0.15,
"input": "error0"
},
"minNumberIterations": {
"criteria": "xmc.methodDefs_monoCriterion.criterionFunctions.isGreaterThanOrEqualTo",
"tolerance": [0],
"tolerance": 0.0,
"input": "algorithmCost"
},
"maxNumberIterations": {
"criteria": "xmc.methodDefs_monoCriterion.criterionFunctions.isGreaterThanOrEqualTo",
"tolerance": [0],
"tolerance": 0.0,
"input": "algorithmCost"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import KratosMultiphysics.MultilevelMonteCarloApplication
import xmc
import xmc.methodDefs_momentEstimator.computeCentralMoments as mdccm
from exaqute.ExaquteTaskLocal import *
from exaqute import get_value_from_remote


if __name__ == "__main__":

Expand All @@ -24,9 +25,8 @@
with open(parametersPath,'r') as parameter_file:
parameters = json.load(parameter_file)

# add path of the problem folder to python path
problem_id = parameters["solverWrapperInputDictionary"]["problemId"]
sys.path.append(os.path.join("..","xmc","classDefs_solverWrapper","problemDefs_KratosMultiphysics",problem_id))
# SolverWrapper
parameters["solverWrapperInputDictionary"]["qoiEstimator"] = parameters["monteCarloIndexInputDictionary"]["qoiEstimator"]

# SampleGenerator
samplerInputDictionary = parameters["samplerInputDictionary"]
Expand All @@ -37,19 +37,6 @@
monteCarloIndexInputDictionary = parameters["monteCarloIndexInputDictionary"]
monteCarloIndexInputDictionary["samplerInputDictionary"] = samplerInputDictionary

# Moment Estimators
qoiEstimatorInputDictionary = parameters["qoiEstimatorInputDictionary"]
combinedEstimatorInputDictionary = parameters["combinedEstimatorInputDictionary"]
costEstimatorInputDictionary = parameters["costEstimatorInputDictionary"]
# qoi estimators
monteCarloIndexInputDictionary["qoiEstimator"] = [monteCarloIndexInputDictionary["qoiEstimator"][0] for _ in range (0,parameters["solverWrapperInputDictionary"]["numberQoI"])]
monteCarloIndexInputDictionary["qoiEstimatorInputDictionary"] = [qoiEstimatorInputDictionary]*parameters["solverWrapperInputDictionary"]["numberQoI"]
# combined estimators
monteCarloIndexInputDictionary["combinedEstimator"] = [monteCarloIndexInputDictionary["combinedEstimator"][0] for _ in range (0,parameters["solverWrapperInputDictionary"]["numberCombinedQoi"])]
monteCarloIndexInputDictionary["combinedEstimatorInputDictionary"] = [combinedEstimatorInputDictionary]*parameters["solverWrapperInputDictionary"]["numberCombinedQoi"]
# cost estimator
monteCarloIndexInputDictionary["costEstimatorInputDictionary"] = costEstimatorInputDictionary

# MonoCriterion
criteriaArray = []
criteriaInputs = []
Expand Down Expand Up @@ -153,25 +140,20 @@
qoi_dict["qoi_id_"+str(qoi_counter)]["index_"+str(index)] = {"qoi_id":qoi_counter, "index": index, "instances": sample_counter, "S1": S1, "S2": S2, "S3": S3, "S4": S4, "S5": S5, "S6": S6, "S7": S7, "S8": S8, "S9": S9, "S10": S10, "h1": h1, "h2": h2,"type":"scalar_quantity","tag":"lift_coefficient"}

# save pressure coefficient
qoi_counter = qoi_counter + 1
qoi_dict["qoi_id_"+str(qoi_counter)] = {"member_"+str(member): {} for member in range (algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter]._variableDimension)}
member = 0
for node in current_model.GetModelPart(model_part_of_interest).Nodes:
qoi_counter = qoi_counter + 1
qoi_dict["qoi_id_"+str(qoi_counter)] = {"index_"+str(index): {} for index in range (len(algo.monteCarloSampler.indices))}
qoi_dict["qoi_id_"+str(qoi_counter)]["member_"+str(member)] = {"index_"+str(index): {} for index in range (len(algo.monteCarloSampler.indices))}
for index in range (len(algo.monteCarloSampler.indices)):
algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter] = get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter])
sample_counter = algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter]._sampleCounter
S1 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[0][0]))
S2 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[1][0]))
S3 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[2][0]))
S4 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[3][0]))
S5 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[4][0]))
S6 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[5][0]))
S7 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[6][0]))
S8 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[7][0]))
S9 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[8][0]))
S10 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter].powerSums[9][0]))
S1 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter]._powerSums["1"][member]))
S2 = float(get_value_from_remote(algo.monteCarloSampler.indices[index].qoiEstimator[qoi_counter]._powerSums["2"][member]))
h1 = float(get_value_from_remote(mdccm.computeCentralMomentsOrderOneDimensionZero(S1,sample_counter)))
h2 = float(get_value_from_remote(mdccm.computeCentralMomentsOrderTwoDimensionZero(S1,S2,sample_counter)))
qoi_dict["qoi_id_"+str(qoi_counter)]["index_"+str(index)] = {"qoi_id":qoi_counter, "index": index, "instances": sample_counter, "S1": S1, "S2": S2, "S3": S3, "S4": S4, "S5": S5, "S6": S6, "S7": S7, "S8": S8, "S9": S9, "S10": S10, "h1": h1, "h2": h2,"type":"scalar_quantity","tag":"pressure coefficent","node_id":node.Id,"node_coordinates":[node.X,node.Y,node.Z]}
qoi_dict["qoi_id_"+str(qoi_counter)]["member_"+str(member)]["index_"+str(index)] = {"qoi_id":qoi_counter, "member":member, "index": index, "instances": sample_counter, "S1": S1, "S2": S2, "S3": S3, "S4": S4, "S5": S5, "S6": S6, "S7": S7, "S8": S8, "S9": S9, "S10": S10, "h1": h1, "h2": h2,"type":"scalar_quantity","tag":"pressure coefficent","node_id":node.Id,"node_coordinates":[node.X,node.Y,node.Z]}
member += 1

# save to file
with open('power_sums_outputs/MC_asynchronous_power_sums_' +str(time.time()) + '.json', 'w') as f:
Expand Down
Loading