Source code for viiapackage.results.overburden_load.overburden_load_to_excel

### ===================================================================================================================
###   Function to export overburdenloads to excel
### ===================================================================================================================
# Copyright ©VIIA 2024

### ===================================================================================================================
###   1. Import modules
### ===================================================================================================================

# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, List
from openpyxl import Workbook
from datetime import datetime
from pathlib import Path

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.shapes import Wall

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject


### ===================================================================================================================
###   2. Function overburden_load_to_excel
### ===================================================================================================================

[docs]def overburden_load_to_excel(project: ViiaProject, walls: List[Wall]) -> Path: """ This function writes the overburden loads for the walls in the list to an Excel-file. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - walls (list of obj): List of wall objects to save the overburdenload to excel for. Output: - Generates an Excel-sheet in the workfolder with the overburden loads per wall. """ # Write overburden load to Excel file # The default name of the Excel-file is set and opened generated = datetime.now().strftime('%d-%m-%Y_%H%M%S') document = f'{project.name}_overburden_load_{generated}.xlsx' file = project.workfolder_location / document wb = Workbook() load_sheet = wb.active # Set column width in Excel load_sheet.column_dimensions['A'].width = 35 load_sheet.column_dimensions['B'].width = 25 # Fill in data in Excel counter = 2 for wall in walls: if wall.meta_data and 'overburden_load' in wall.meta_data: load_sheet[f'A{counter}'] = wall.name load_sheet[f'B{counter}'] = wall.meta_data['overburden_load'] / 1000 counter += 1 # Standard information load_sheet['A1'] = 'Wall name' load_sheet['B1'] = 'Overburden load [kN/m]' # Information on current run load_sheet['C1'] = generated # Save the updated Excel in the working directory wb.save(document) # Notification project.write_log(f"Overburden load from fem-model are exported to excel.\nFile: {file.as_posix()}.") return file
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================