{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Connecting to server...\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import sys\n",
    "\n",
    "from RFEM.initModel import Model, Calculate_all\n",
    "from RFEM.enums import (\n",
    "    NodalSupportType, SurfaceGeometry, SurfaceLoadDirection,\n",
    "    SurfaceLoadDistribution, ActionCategoryType, LineSupportType,\n",
    "    MemberLoadDirection, MemberLoadDistribution, MemberType,\n",
    "    CaseObjectType\n",
    ")\n",
    "from RFEM.BasicObjects.node import Node\n",
    "from RFEM.BasicObjects.line import Line\n",
    "from RFEM.BasicObjects.material import Material\n",
    "from RFEM.BasicObjects.thickness import Thickness\n",
    "from RFEM.BasicObjects.surface import Surface\n",
    "from RFEM.BasicObjects.member import Member\n",
    "from RFEM.BasicObjects.section import Section\n",
    "from RFEM.TypesForLines.lineSupport import LineSupport\n",
    "from RFEM.TypesForNodes.nodalSupport import NodalSupport\n",
    "from RFEM.LoadCasesAndCombinations.loadCase import LoadCase\n",
    "from RFEM.LoadCasesAndCombinations.staticAnalysisSettings import StaticAnalysisSettings\n",
    "from RFEM.Loads.surfaceLoad import SurfaceLoad\n",
    "from RFEM.Loads.memberLoad import MemberLoad\n",
    "from RFEM.Loads.lineLoad import LineLoad\n",
    "from RFEM.ImportExport.exports import ExportTo\n",
    "from RFEM.Results.resultTables import ResultTables, GetMaxValue, GetMinValue\n",
    "from RFEM.dataTypes import inf\n",
    "\n",
    "\n",
    "# Neues leeres Modell mit Reset\n",
    "Model(True, 'MeinTestModell')\n",
    "Model.clientModel.service.delete_all()  # 🔁 Alles löschen!\n",
    "Model.clientModel.service.begin_modification()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# GENERAL PROMPT\n",
    "\n",
    "#### I want to create a cylindrical steel pressure vessel with a diameter of 2m, heigt 5 m and an upper lid under snow load on the top. The support is at the bottom circular line. the thickness of the lid is 10 mm and for the cylinder shell 4 mm. the magnitude of the snow load is 0.25 kN/m²."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# MATERIAL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<RFEM.BasicObjects.material.Material at 0x235fc212270>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# ---- Material Sec ----\n",
    "Material(no=1, name=\"S235\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# GEOMETRY"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<RFEM.TypesForNodes.nodalSupport.NodalSupport at 0x23582cb9a90>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "# ---- Geometry ----\n",
    "Node(1, 0, 0, 0)\n",
    "Node(2, 5, 0, 0)\n",
    "\n",
    "# ---- Section & Material ----\n",
    "Material(1, 'S235')\n",
    "Section(1, 'IPE 300', 1)\n",
    "\n",
    "# ---- Member----\n",
    "Member(1, 1, 2, 0.0, 1, 1)\n",
    "\n",
    "# ---- Supports ----\n",
    "NodalSupport(1, '1', NodalSupportType.HINGED)\n",
    "NodalSupport(2, '2', NodalSupportType.HINGED)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CROSSSECTION"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<RFEM.BasicObjects.section.Section at 0x23582cba490>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Section(1, 'IPE 300', 1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# LOADS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<RFEM.Loads.memberLoad.MemberLoad at 0x23584ed8440>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# ---- Loads Sec ----\n",
    "\n",
    "# Define a load case with self-weight included\n",
    "LoadCase(no=1, name='Self-weight and Member Load', self_weight=[True, 0.0, 0.0, 1.0])\n",
    "\n",
    "# Define a member load acting downwards in the local Z direction\n",
    "MemberLoad(no=1, load_case_no=1, members_no='1', load_direction=MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z, magnitude=3 * 1000)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# APPLY CALL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "Model.clientModel.service.finish_modification()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Calculate Call"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<suds.sudsobject.calculation_result at 0x23582cbad50>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Calculate_all()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# GET RESULTS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# ---- Results for Einfeldträger ----\n",
    "\n",
    "# Verschiebung (in mm)\n",
    "dispTable = ResultTables.MembersGlobalDeformations(CaseObjectType.E_OBJECT_TYPE_LOAD_CASE, 1, 1)\n",
    "maxDisp = GetMaxValue(dispTable, 'displacement_absolute') * 1000  # [m] → [mm]\n",
    "\n",
    "# Biegemoment (in kNm)\n",
    "momentTable = ResultTables.MembersInternalForces(CaseObjectType.E_OBJECT_TYPE_LOAD_CASE, 1, 1)\n",
    "maxMoment = GetMaxValue(momentTable, 'internal_force_my') / 1000  # [Nm] → [kNm]\n",
    "\n",
    "# Querkraft (in kN)\n",
    "shearTable = ResultTables.MembersInternalForces(CaseObjectType.E_OBJECT_TYPE_LOAD_CASE, 1, 1)\n",
    "maxShear = GetMaxValue(shearTable, 'internal_force_vz') / 1000  # [N] → [kN]\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
