from haskoning_atr_tools.human_induced_vibrations import (
    calculate_walking_load,
    create_walking_load_reporting_data,
    create_walking_load_report,
)
from haskoning_structural import *

# Define the path to where the report should be saved
reporting_folder = Path(r'path_to_where_the_report_should_be_saved')

# Create a fem project to read a fem model json
project = fem_start_project(project_name='Walking_load')
# Read the JSON files with the model and the results
project.read_dump(file_name=r'path_to_the_model_json')
project.read_dump(file_name=r'path_to_the_result_json', is_result=True)
# Find the analysis with the walking load
analysis = project.find(description='Walking load', collection='analyses')
# Find the mesh node that is loaded with the walking load
loaded_node = project.find_node(point=[5, 5, 0])
# Get the mesh nodes for which the report should be created
mesh_nodes = [
    project.find_mesh_node(coordinates=[1, 1, 0]),
    project.find_mesh_node(coordinates=[2, 2, 0]),
    project.find_mesh_node(coordinates=[3, 3, 0]),
    project.find_mesh_node(coordinates=[4, 4, 0])]
# Regenerate the walking load with the same parameters as used in the analysis to make sure the report is created with
# the correct load time series
step_walking_load = calculate_walking_load(step_frequency=2, body_mass=90, nr_steps=15, load_reduction=False)

# Generate all the data for the report and create the report
data = create_walking_load_reporting_data(
        project=project, analysis=analysis, step_walking_load=step_walking_load, mesh_nodes=mesh_nodes,
        loaded_node=loaded_node, directions=['x', 'y', 'z'], reporting_folder=reporting_folder, add_zeros=True)
create_walking_load_report(data=data, reporting_folder=reporting_folder)