-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuzzard.py
More file actions
76 lines (66 loc) · 2.46 KB
/
buzzard.py
File metadata and controls
76 lines (66 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
#
# ____ _
# | __ ) _ _ __________ _ _ __ __| |
# | _ \| | | |_ /_ / _` | '__/ _` |
# | |_) | |_| |/ / / / (_| | | | (_| |
# |____/ \__,_/___/___\__,_|_| \__,_|
#
#
# Unit of Strength of Materials and Structural Analysis
# University of Innsbruck,
# 2021 - today
#
# Alexander Dummer alexander.dummer@uibk.ac.at
#
# This file is part of Buzzard.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# The full text of the license can be found in the file LICENSE.md at
# the top level directory of Buzzard.
# ---------------------------------------------------------------------
import argparse
import os
import buzzard.core.optimizer
import buzzard.utils.journal
from buzzard.core.optimizer import runOptimization
from buzzard.utils.journal import printHeader
from buzzard.utils.reader import readConfig, readConfigFromJson
from buzzard.utils.writers import writeInputFilesForInitialParameters
if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="buzzard",
description="A tool for optimizing (material) parameters for finite element simulations",
)
parser.add_argument(
"file",
type=str,
nargs=1,
)
parser.add_argument("--parallel", action="store_true", default=False)
parser.add_argument("--createPlots", action="store_true", default=False)
parser.add_argument("--quiet", action="store_true", default=False)
parser.add_argument("--writeInputOnly", action="store_true", default=False)
args = parser.parse_args()
buzzard.core.optimizer.executeSimulationsInParallel = args.parallel
buzzard.core.optimizer.createPlots = args.createPlots
buzzard.utils.journal.quiet = args.quiet
printHeader()
configFile = args.file[0]
root, ext = os.path.splitext(configFile)
if ext == ".py":
config = readConfig(configFile)
elif ext == ".json":
config = readConfigFromJson(configFile)
else:
raise Exception("File type of config file must be .py or .json")
if args.writeInputOnly:
writeInputFilesForInitialParameters(config)
print("Write input files only")
exit()
result = runOptimization(config)