File: t_AnsysParser_std.py

package info (click to toggle)
persalys 13.1.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 71,916 kB
  • sloc: xml: 496,859; cpp: 53,848; python: 3,435; sh: 332; makefile: 131; ansic: 14
file content (41 lines) | stat: -rw-r--r-- 1,140 bytes parent folder | download
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
import os
import platform
import persalys
# import openturns as ot
import openturns.testing as ott

# testcase using ansys connector
key_platform = platform.system()
dict_exe = {
    "Linux": ["dummyAnsys", "./dummyAnsys"],
    "Windows": ["dummyAnsys.exe", "dummyAnsys.exe"],
}

pathHere = os.path.dirname(os.path.abspath(__file__))
pathResources = os.path.join(pathHere, "ansysConnector")
modelFile = os.path.join(pathResources, "BEAM.wbpj")
ansysExec = dict_exe[key_platform][0]
templateFile = "input.txt.in"

step = persalys.CouplingStep()
model = persalys.CouplingPhysicalModel("A", [step])

parser = persalys.AnsysParser(modelFile)
parser.populateCouplingStep(model, 0, templateFile)

# Required for testing because of dummyAnsys
step = model.getSteps()[0]
resourceFiles = step.getResourceFiles()
resourceFiles.add(persalys.CouplingResourceFile(ansysExec))
step.setResourceFiles(resourceFiles)
command = step.getCommand()
step.setCommand(dict_exe[key_platform][1] + command)

model.setSteps([step])
x = [1.0, 2.0, 3.0, 4.0, 5.0]
f = model.getFunction()
y = f(x)
print(y)
ott.assert_almost_equal(y, [0.10662])

os.remove(templateFile)