.. _ABAQUS-label:

============================================
Seismic analysis with NLTH in ABAQUS in VIIA
============================================
This page contains the protocol for NLTH analyses with ABAQUS software. It extends on the NLTH for DIANA part of the
protocol.

.. warning:: This document is not updated for new developments as the NLTH in ABAQUS software  is currently not in the
    VIIA workflow.

.. _ABAQUSProcess-label:

--------------
ABAQUS process
--------------
The models in ABAQUS software like in DIANA are complex and contain lots of detailed information. This means that
mistakes can easily be made, and that the cause is not always clear. The workflow process for ABAQUS presented here aim 
to prevent errors, by applying complexity in small steps. In this section, the ABAQUS specific actions are described in 
order to obtain a reliable model. The steps are described in the subsequent sections.

.. _ABAQUSVersion-label:

Version
=======
Currently the models are built and calculated in ABAQUS 2020. This is also the version available on the servers where
this viiaPackage is working on. It may be that with a new release the syntax, or the operation of the software, has
changed. That is why at the beginning of a batch it is determined which version should be used. In some cases it is
possible to model in a newer version, and then to perform the calculation (inp) in the agreed version. In a newer
version, the functions of the viiaPackage can have an unexpected result or even caused errors.

.. _ABAQUSLicences-label:

Licenses
========
RHDHV has a limited of licenses for the use of ABAQUS that are updated annually. The current licenses expires in April,
2020. The experience is that a licensing update does not go smoothly and that, with regard to the expiration of the
license, this must be taken into account when using the license in that period.

ABAQUS works with modules for which different a number of licenses are available. The current distribution of the
licenses is as follows:

+----------------------------------------------------------------------------------------------------------------------+
| Table - Network licenses ABAQUS (2020)                                                                               |
+================+====================+================================================================================+
| Module         | Number of licenses | Description module                                                             |
+----------------+--------------------+--------------------------------------------------------------------------------+
| CAE            | 3                  | Pre- / Post-Processing with ABAQUS CAE/Viewer                                  |
+----------------+--------------------+--------------------------------------------------------------------------------+
| ABAQUS         | 21                 | Analyses                                                                       |
+----------------+--------------------+--------------------------------------------------------------------------------+

In order to check license usage following command should be executed in the terminal:

>>> abaqus licensing lmstat -c 27000@NLOUMFOPLIC016.corporateroot.net -A

Once licenses are used the returned text from the command is as follows:

.. figure:: _static/abaqus/LicenseServerAbaqus.png
    :align: center

    Abaqus license usage example.

In figure above marked fields are as follows:

1. Licenses type used. Only important types for VIIA are abaqus and cae. 
2. Total number of available licenses.
3. Total number of licenses used. 
4. User id that is using the licenses (if excessive usage is noticed and no free licenses are available to you, you can 
   contact the user to discuss their planing and the availability of the licenses).
5. Number of licenses used per instance (one analysis or one instance of CAE/Viewer) 

The license server has a name: NLOUMFOPLIC016.corporateroot.net and port: 27000

When using Abaqus CAE or Abaqus Viewer 1 (CAE) license will be consumed. Additional CAE licenses will consumed per
additional instance of CAE/Viewer even if they are opened on the same computer. In order to estimate how many licenses
your analysis will use a formula can be employed:

.. math::
   Licenses = INT(5 * N_{cores}^{0.422})
   :label: AbaqusLicenses

where :math:`N_{cores}` is number of cores used for the analysis.

Servers
=======
Currently in RHDHV there is only one server suitable for analysis with Abaqus. The server uses the network
licenses, in the same way as ABAQUS licenses are used by the local laptop. The servers not only ensure that long
calculations can continue, that the laptop remains available for other purposes and that large files remain manageable
but also significantly speeds up calculation time. However, unlike DIANA, only one ABAQUS analysis can run on the server
at any time. Not only that but also no DIANA analysis or any other computationally intensive process are allowed to run 
on the server when ABAQUS calculation is running. This is because explicit analyses are very efficient and uses 
computer resources to the maximum, this means that running analysis parallel will not only not gain any extra speed, but
also be slower that running same analyses sequently due to competing processes.

| \\\NLRTMGHPAPS010.corporateroot.net\\EXCHANGE

.. note:: The servers are not connected to the BOX and are not intended to store data.

For more information on the servers: :ref:`VIIAservers-label`.

Performing analyses in ABAQUS
=============================
To perform calculations in ABAQUS, an analysis must be created. Running the analysis can be done directly
in the graphical user interface (GUI) of ABAQUS, or by running it in a Command Box.

A point of attention is the export of data. The more output selected, the bigger is the output file. If not careful
for large analyses an output of one analysis can take up the space on a disk on the server. Only ask for needed output.
Explicit uses significantly more calculation increments than implicit, therefor without being careful one might end up 
with unworkable results file.
While the calculation is running in ABAQUS CAE, the program can be used as usual. It is also possible to carry out a 
calculation via the Command Box. The advantage of calculating in the Command Box is no CAE licenses are taken when
running a calculation. We strongly encourage to only use Command Box for starting of the calculations, due to limited
number of licenses.

To calculate in the Command Box, the model must be exported to a .inp-file.

To start a calculation, navigate through the Command Box to the correct path and use the following syntax:

>>> abaqus -j name.inp cpus=4 double=both -seq

The number of cpus depend on the system you are running the calculation. Local laptops tend to have 4 to 8 cpus. Servers
can have much more. The more cpus you use the faster the analysis will be, but please calculate the token usage before
running the calculation according to the formula :eq:`AbaqusLicenses` and check if you have enough licenses available.

At the moment we do not have enough licenses, if only enough licenses are available for analysis with 1 core and you 
start with 8 cores, your analysis will be stuck until more licenses become available, which can take days.

.. figure:: _static/abaqus/ABAQUSCommandBox.png
    :align: center

    Calculations via the ABAQUS Command Box.

The advice is to create a folder per calculation, so that calculation files and result files remain bundled. This
prevents confusion about which .inp to which .odb belongs. A new calculation in the same folder with the
same output filename will overwrite the old files. The functions in the viiaPackage will help in this process.

Bug fixing in ABAQUS
====================
It is possible that ABAQUS gives errors during an analysis. These error messages are due to incorrect modelling or
because ABAQUS is a program in development and therefore not always work properly. In the latter case, a workaround is
usually required (and available for known errors). The error messages are generally described very clearly and sometimes
even have an explanation how they can be fixed. However, sometimes they are very cryptic. In that case , it is advisable 
to ask a colleague for help. It may be that this error is already known. If the problem is not solved yet, contact
ABAQUS support. Do not forget to inform your technical master about the error so all errors can be tracked.

.. _ABAQUSenergybalance-label:

Energy balance
==============
Because explicit type analysis do not search for convergence it is important to check if the results of the analysis are
still trust worthy. This can be done by checking the graphs of kinetic energy plotted together with total energy. The
total energy is total energy balance in the system. As your calculation is a closed system there should be a perfect
equilibrium between the energies that enter it and energies that leave it. However, this being a numerical analysis this
is not possible. In order to quantify the energy drift (balance being negative or positive instead of zero) a rule can
be agreed that the calculation is trust worthy (as long as all the input is correct) if the total energy at the end of
the calculation is no bigger than 5% of the maximum kinetic energy in the analysis.

.. figure:: _static/abaqus/ABAQUS_energy_balance.png
    :align: center

    Energy balance in ABAQUS.

Though, if the this ratio is exceeding it does not mean that the whole analysis is incorrect. The drift can be caused by
local instability. In that case it is important to identify the location of such instability so the results at the 
location could be ignored. 

.. figure:: _static/abaqus/ABAQUS_energy_balance_wrong.png
    :align: center

    Wrong energy balance in ABAQUS.

.. figure:: _static/abaqus/ABAQUS_energy_balance_cause.png
    :align: center

    Cause of wrong energy balance in ABAQUS.

.. _Element_mass_scaling_factor_check:

Element mass scaling factor check
=================================
Mass scaling (EMSF) is used in ABAQUS for computational efficiency in dynamic analysis. The mass scaling can be
performed by scaling the masses of all specified elements by a user-supplied constant factor. For NLTH and non-linear
static analysis, this factor should not exceed 1e-04. In order to check the mass scaling factor, the output 'EMSF'
should be added to the output block of NLTH and non-linear static analysis.

------------------------
Phase 1 - Starting phase
------------------------
There are no specific additions for NLTH with ABAQUS software.

---------------------------------
 Phase 2 - Fixed base model phase
---------------------------------

Step 8: Apply the boundary conditions and base motions for fixed base to the model
==================================================================================

Load combinations
-----------------
After creating the load cases, these must be combined. DIANA only performs calculations from load combinations. In
ABAQUS loads that are defined in a step can be used directly.

Step C1: Mesh Check
===================
To check whether the line elements have been entered correctly, the function
:py:func:`~viiapackage.viiaChecking._viia_check_beam_rotation` can be used. It checks whether line elements can rotate
around their own axis. In ABAQUS this check can be done directly on the geometry, no meshing is required.

Step A2: Rob-test (Optional)
============================

.. note:: Rob-test type analysis is not supported in ABAQUS.

Step A4: Linear fixed base LTH analysis (Optional)
==================================================

.. note:: Linear fixed base LTH analysis type analysis is not supported in ABAQUS.

Step A5: Modal Response Spectrum analysis
=========================================

.. warning:: The modal response spectrum analysis is not available for ABAQUS.

------------------------------
Phase 3 - Flexbase model Phase
------------------------------

Step 8: Apply the boundary conditions and base motions for fixed base to the model
==================================================================================

.. note:: For ABAQUS analyses the flexbase foundation for shallow foundations is currently not used. It is agreed with
    the knowledgeteam to keep it fixedbase. Once the flexbase is available in ABAQUS, this chapter will be updated.

Step A5: MRS analysis of floors / roofs
=======================================

.. note:: A5 type analysis is not supported in ABAQUS.

Step C2: Model check
====================
Per analyses the following items need to be provided (ABAQUS):

- cae-file
- inp-file
- dat-file
- log-file
- sta-file
- Result files ABAQUS native (.odb)
- Results handled for tabulated files (if .tb are generated)

Step A11: Nonlinear flexbase push-over analysis
===============================================

.. note:: A11 type analysis is not supported in ABAQUS.

Step A12: Nonlinear flexbase NLTH analysis (7x)
===============================================
Using the function :py:func:`~viiapackage.viiaAnalysis.viia_analysis`, a time-history can be applied with the
appropriate set of result items. Set the *run* argument to the default *'False'*, indicating to prepare the
inp-files for calculations in ABAQUS.

Issues
------
For ABAQUS if the analyses crash:
   
   * Check your model carefully, it is very likely that the crash results from modeling errors.
   * Check the deformations and the behaviour of the model troughout the NLTH signal, make sure you understand the reson
     for large displacements/forces.
   * Read carefully the warnings produced by the FEA software. Make sure you understand the reason for them and the 
     implications.
   * If issues still persist, contact your collegue or technical master for assistence.

-------------------
Phase 4 - Reporting
-------------------
There are no specific additions for NLTH with ABAQUS software.

-----------------------------
Phase 5 - Strengthening phase
-----------------------------

Step 14: Modelling of strengthening measures
============================================
The same guidelines also applies to the modelling of measures for NLTH in ABAQUS.