### ===================================================================================================================
### A1 linear static analysis result handling
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
import json
from datetime import date
from pathlib import Path
from typing import TYPE_CHECKING, Dict, Optional
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
from viiapackage.results.result_functions.viia_foundation_area import viia_foundation_area
### ===================================================================================================================
### 2. Function to combine information in model with results from software for A1 analysis
### ===================================================================================================================
[docs]def viia_collect_results_a1(
project: ViiaProject, center_of_mass: Dict[str, float], json_file: Path) -> Dict[str, Optional[float]]:
"""
Combining information from the out-file from DIANA or dat-file from ABAQUS with data of the model itself.
Includes:
- Aggregation of A1 results.
Input:
- project (obj): VIIA project object containing collections of fem objects and project variables.
- center_of_mass (dict): Dictionary with required information from the analysis. The required keys are
'sum_vertical_loads', 'center_of_mass_x' and 'center_of_mass_y'. The values are floats.
- json_file (path): Path of the json-file of the model.
Output:
- Returns dictionary with collected information required for the A1 analysis.
"""
# Check if mass is provided, then convert to sum vertical loads
if 'total_mass' in center_of_mass and 'sum_vertical_loads' not in center_of_mass:
center_of_mass['sum_vertical_loads'] = center_of_mass['total_mass'] * project.gravitational_acceleration
# Notification and logging
project.write_log(
f"The sum of the vertical loads is {round(center_of_mass['sum_vertical_loads'] / 1000, 1)} kN.")
project.write_log(
f"The center of mass is x: {round(center_of_mass['center_of_mass_x'], 3)} m and y: "
f"{round(center_of_mass['center_of_mass_y'], 3)} m.")
# Collect the model to be sent
with open(json_file) as f:
data = json.load(f)
# Collect the area of the shallow foundation
area = viia_foundation_area(project=project)[0]
if area is None:
area = 0.
# Collect the name of the analysis, normal use is the timestamp at creation of the files (folder name)
name = str(json_file.parent.name)
if name == 'input':
name = 'TestRun'
# Collect the inputs required for the endpoint in MYVIIA
return {
'area_foundation': area,
'center_of_gravity_x': center_of_mass['center_of_mass_x'],
'center_of_gravity_y': center_of_mass['center_of_mass_y'],
'date': str(date.today()),
'model': data,
'name': name,
'object_deel_id': project.get_myviia_object_deel_id(),
'weight_of_building': center_of_mass['sum_vertical_loads']}
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================