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
30 changes: 23 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ if ( BarElm_LIBRARY )
endif ( BarElm_LIBRARY )

if ( BUILD_SOLVER_AS_DLL )
# Check if python is installed
if ( CMAKE_VERSION VERSION_LESS 3.12 )
find_package ( PythonInterp 3 ) # sets ${PYTHON_EXECUTABLE}
else ( CMAKE_VERSION VERSION_LESS 3.12 )
Expand All @@ -60,6 +61,8 @@ if ( BUILD_SOLVER_AS_DLL )
endif ( PythonInterp_FOUND )
endif ( BUILD_SOLVER_AS_DLL )

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

set ( FT_TOLERANCE 1.0e-12 CACHE STRING "Regression test comparison tolerance" )
option ( FT_LARGE_MODELS "Include large regression test models" false )
option ( FT_RUN_VALGRIND "Run regression tests with valgrind" false )
Expand All @@ -77,15 +80,20 @@ if ( VALGRIND )
set ( VALGRIND_CMD ${VALGRIND} --leak-check=full --show-leak-kinds=all )
endif ( VALGRIND )

################################################################################
# Create a custom target to copy relevant input files into the build tree.

add_custom_target ( copy_test_input_files )
foreach ( TEST ${TEST_DIRS} )
set ( TIME_DOMAIN TimeDomain/${TEST} )
set ( FREQ_DOMAIN FrequencyDomain/${TEST} )
set ( BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/${TEST} )
set ( CML_TDA ${CMAKE_CURRENT_SOURCE_DIR}/TimeDomain/${TEST}/CMakeLists.txt )
set ( CML_FDA ${CMAKE_CURRENT_SOURCE_DIR}/FrequencyDomain/${TEST}/CMakeLists.txt )
set ( CML_TDA ${CMAKE_CURRENT_SOURCE_DIR}/${TIME_DOMAIN}/CMakeLists.txt )
set ( CML_FDA ${CMAKE_CURRENT_SOURCE_DIR}/${FREQ_DOMAIN}/CMakeLists.txt )
if ( EXISTS ${CML_TDA} )
set ( SRC_DIR TimeDomain/${TEST} )
set ( SRC_DIR ${TIME_DOMAIN} )
elseif ( EXISTS ${CML_FDA} AND FFT_LIBRARY )
set ( SRC_DIR FrequencyDomain/${TEST} )
set ( SRC_DIR ${FREQ_DOMAIN} )
elseif ( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TEST}/CMakeLists.txt )
set ( SRC_DIR ${TEST} )
else ( EXISTS ${CML_TDA} )
Expand All @@ -94,9 +102,17 @@ foreach ( TEST ${TEST_DIRS} )
add_subdirectory ( ${SRC_DIR} ${BIN_DIR} )
set ( SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_DIR} )
add_custom_command ( TARGET copy_test_input_files POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${SRC_DIR} ${BIN_DIR} )
COMMAND ${CMAKE_COMMAND} -E copy_directory
${SRC_DIR} ${BIN_DIR} )
add_custom_command ( TARGET copy_test_input_files POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove -f
${BIN_DIR}/*.md ${BIN_DIR}/CMakeLists.*
${BIN_DIR}/*/*.md ${BIN_DIR}/*/*.png ${BIN_DIR}/*/CMakeLists.* )
${BIN_DIR}/*.md ${BIN_DIR}/*/*.md
${BIN_DIR}/CMakeLists.* ${BIN_DIR}/*/CMakeLists.* )
if ( "${TEST}" STREQUAL "InversePy" )
add_custom_command ( TARGET copy_test_input_files POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove -f
${BIN_DIR}/*.py ${BIN_DIR}/*/run_API.py )
add_custom_command ( TARGET copy_test_input_files POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory ${BIN_DIR}/img )
endif ( "${TEST}" STREQUAL "InversePy" )
endforeach ( TEST ${TEST_DIRS} )
2 changes: 1 addition & 1 deletion InversePy/beam_longitudinal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ The curve plot shows the measurements (reference) as line,
the results from the inverse method are presented as points.
The results satisfy the criterion of acceptance.

![Longitudinal beam](longitudinal.PNG "Longitudinal beam response")
![Longitudinal beam](../img/longitudinal.png "Longitudinal beam response")
15 changes: 6 additions & 9 deletions InversePy/beam_longitudinal/run_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
plot_curves = False # False for no plots


def run_simulation(inp):
def run_simulation(inp, print_stepping):

init_length = 1.0

twin_funcId = [5] # 5 .. rel distance triad 113-112

twinmodel = FedemRun(".", inp)
twinmodel = FedemRun(".", inp, print_stepping)

# holds the results from the base data (graphical/numerical comparison)
baseRes = []
Expand All @@ -31,9 +31,6 @@ def run_simulation(inp):

# ======================= TIME LOOP ==========================
for n in range(inp["total_increments"]):
print("\n+++++++++++++++++++++++++++++++++++++++++++++")
print("Solving time increment", n)

base[0] = baseD[n] - init_length # data modification based on base output
baseRes.append([baseD[n]])

Expand All @@ -43,13 +40,13 @@ def run_simulation(inp):

twinRes.append(twin)

twinmodel.solver_done()
twinmodel.done_inverse()
return baseRes, twinRes


def main():
def main(print_stepping=False):

baseR, twinR = run_simulation(utils.read_input())
baseR, twinR = run_simulation(utils.read_input(), print_stepping)

# graphical output with matplotlib
if plot_curves:
Expand All @@ -64,6 +61,6 @@ def main():


if __name__ == "__main__":
main()
main(not utils.parse_input().no_print)

# end of file
2 changes: 1 addition & 1 deletion InversePy/beam_modal_forces/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ The curve plots show the measurements (reference) as line,
the results from the inverse method are presented as points.
The results satisfy the criterion of acceptance.

![Transversal beam deflection](modal_forces.png "Transversal beam deflection")
![Transversal beam deflection](../img/modal_forces.png "Transversal beam deflection")
14 changes: 6 additions & 8 deletions InversePy/beam_modal_forces/run_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
plot_curves = False # False for no plots


def run_simulation(inp):
def run_simulation(inp, print_stepping):

twin_funcId = [1, 3, 4] # displacements in DY_17, DY_113 and DY_114

twinmodel = FedemRun(".", inp)
twinmodel = FedemRun(".", inp, print_stepping)

# displacements from file
baseRes = utils.read_data_from_file("./refData.asc")
Expand All @@ -24,8 +24,6 @@ def run_simulation(inp):

# ======================= TIME LOOP ==========================
for n in range(inp["total_increments"]):
print("\n+++++++++++++++++++++++++++++++++++++++++++++")
print("Solving time increment", n)

base = baseRes[n, 0:2] # prepare input for twin, only internal forces

Expand All @@ -35,13 +33,13 @@ def run_simulation(inp):

twinRes.append(twin)

twinmodel.solver_done()
twinmodel.done_inverse()
return baseRes, twinRes


def main():
def main(print_stepping=False):

baseR, twinR = run_simulation(utils.read_input())
baseR, twinR = run_simulation(utils.read_input(), print_stepping)

# graphical output with matplotlib
if plot_curves:
Expand All @@ -54,6 +52,6 @@ def main():


if __name__ == "__main__":
main()
main(not utils.parse_input().no_print)

# end of file
4 changes: 2 additions & 2 deletions InversePy/beam_transversal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ The curve plots show the measurements (reference) as line,
the results from the inverse method are presented as points.
The results satisfy the criterion of acceptance.

![Transversal beam moment](transversal_1.PNG "Transversal beam moment")
![Transversal beam moment](../img/transversal1.png "Transversal beam moment")

![Transversal beam deflection](transversal_2.PNG "Transversal beam deflection")
![Transversal beam deflection](../img/transversal2.png "Transversal beam deflection")
14 changes: 6 additions & 8 deletions InversePy/beam_transversal/run_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@
plot_curves = False # False for no plots


def run_simulation(inp):
def run_simulation(inp, print_stepping):

twin_funcId = [8, 9, 4] # results Mz_17, Qy_113 and Disp_114

twinmodel = FedemRun(".", inp)
twinmodel = FedemRun(".", inp, print_stepping)

baseRes = utils.read_data_from_file("./refData.asc", sep=",")
twinRes = []

# ======================= TIME LOOP ==========================
for n in range(inp["total_increments"]):
print("\n+++++++++++++++++++++++++++++++++++++++++++++")
print("Solving time increment", n)

base = baseRes[n, 0:2] # prepare input for twin, only internal forces

Expand All @@ -33,11 +31,11 @@ def run_simulation(inp):

twinRes.append(twin)

twinmodel.solver_done()
twinmodel.done_inverse()
return baseRes, twinRes


def main():
def main(print_stepping=False):

# Check if yaml file exists, if not use direct input
try:
Expand All @@ -50,7 +48,7 @@ def main():
)
inp['total_increments'] = 1000

baseR, twinR = run_simulation(inp)
baseR, twinR = run_simulation(inp, print_stepping)

# graphical output with matplotlib
# output internal forces
Expand All @@ -73,6 +71,6 @@ def main():


if __name__ == "__main__":
main()
main(not utils.parse_input().no_print)

# end of file
5 changes: 1 addition & 4 deletions InversePy/corner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,10 @@ the data read-in, by using the utility method sensor_data_matrix().
The read-in data columns are specified in the yaml file or by using a
dictionary as parameter in the method `internal_eq`.

The directory contains a .png file showing the match between the base and
twin simulation.

# Response data

The curve plot shows the measurements (reference) as line,
the results from the inverse method are presented as points.
The results satisfy the criterion of acceptance.

![corner](end_triad_position.png "Displacement response at the end triad")
![corner](../img/end_triad_position.png "Displacement response at the end triad")
18 changes: 8 additions & 10 deletions InversePy/corner/run_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
plot_curves = False # False for no plots


def run_simulation(inp):
def run_simulation(inp, print_stepping):

# id 2 deflection, id 3 displacement end triad
twin_funcId = [2, 3]

# initialize analysis model
twinmodel = FedemRun(".", inp)
twinmodel = FedemRun(".", inp, print_stepping)

twinRes = []
baseRes = []

# read the column(s) as specified in the input
# here column 3 (contains the spring force)
dataMat = utils.sensor_data_matrix(inp)
dataMat = utils.sensor_data_matrix(inp, print_stepping)

# As an alternative - reading from file refData.asc
# [0] spring deflection,
Expand All @@ -45,8 +45,6 @@ def run_simulation(inp):

# ======================= TIME LOOP =========================
for n in range(len(dataMat)-1):
print("\n+++++++++++++++++++++++++++++++++++++++++++++")
print("Solving time increment", n)

# extract data from data matrix dataMat (spring force)
force_data = dataMat[n+1,:]
Expand All @@ -59,12 +57,12 @@ def run_simulation(inp):

twinRes.append(twin)

twinmodel.solver_done()
twinmodel.done_inverse()
return baseDisp, baseRes, twinRes


def main():
# Check if yaml file exixts, if not use direct input
def main(print_stepping=False):
# Check if yaml file exists, if not use direct input
try:
inp = utils.read_input()
except:
Expand All @@ -75,7 +73,7 @@ def main():
)

# Run inverse method (static case)
bdsp, baseR, twinR = run_simulation(inp)
bdsp, baseR, twinR = run_simulation(inp, print_stepping)

# take second column from baseR (contains the displacements of the end triad)
tdisp = [ [tr[1]] for tr in twinR]
Expand All @@ -101,6 +99,6 @@ def main():


if __name__ == "__main__":
main()
main(not utils.parse_input().no_print)

# end of file
5 changes: 1 addition & 4 deletions InversePy/crane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ the spring deflection and the spring force in z direction at the
revolute joint (several data are given for controlling the functionality, column 1 and
3 must have the same measurements).

In the directory is a .png file showing the match between the base and
twin simulation.

# Response data

The curve plot shows the measurements (reference) as line,
Expand All @@ -67,4 +64,4 @@ The results satisfy the criterion of acceptance.

The figure below shows a section of the analysis.

![crane_detail](results_zoomView.png "Displacement response at the end triad")
![crane_detail](../img/results_zoomView.png "Displacement response at the end triad")
22 changes: 11 additions & 11 deletions InversePy/crane/run_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
plot_curves = False # False for no plots


def run_simulation(inp):
def run_simulation(inp, print_stepping):

twin_funcId = [1] # revolute joint, spring force

# initialize model
twinmodel = FedemRun(".", inp)
twinmodel = FedemRun(".", inp, print_stepping)

# read in data from base run, file contains 4 colums
# [0] strut_tz, revolute joint, z trans, length
Expand All @@ -40,17 +40,17 @@ def run_simulation(inp):

# ======================= TIME LOOP =========================
for n in range(inp['total_increments']):
print("\n+++++++++++++++++++++++++++++++++++++++++++++")
print("Solving time increment {}".format(n))

# input joint spring force
base_n[0] = base[n+1][3]

print("before: ", base_n)
if print_stepping:
print("before:", base_n)
# convert revolute Joint spring force to deflection
jointIDs = twinmodel.convert_rev_joint_force(base_n)
print("Convert spring force to displacement for rev joints: ", jointIDs)
print("after: ", base_n)
if print_stepping:
print("Convert spring force to displacement for rev joints:", jointIDs)
print("after:", base_n)

baseSpr.append([base_n[0]])

Expand All @@ -60,11 +60,11 @@ def run_simulation(inp):

twinSpr.append(twin)

twinmodel.solver_done()
twinmodel.done_inverse()
return baseDisp, baseSpr, twinSpr


def main():
def main(print_stepping=False):

try:
inp = utils.read_input()
Expand All @@ -76,7 +76,7 @@ def main():
)
inp['total_increments'] = 10000

baseDisp, baseR, twinR = run_simulation(inp)
baseDisp, baseR, twinR = run_simulation(inp, print_stepping)

# graphical output with matplotlib for forces
if plot_curves:
Expand All @@ -92,4 +92,4 @@ def main():
print("----\nCrane example successfully finished\n----")

if __name__ == "__main__":
main()
main(not utils.parse_input().no_print)
Loading