<commit_before>Quick start
===========

.. currentmodule:: pybar

Loading the library
-------------------

To use **pybar** simply import the library as you would usually do::

    import pybar as pb

That's it! After this, you are ready to start building your model.

Building the model
------------------

A simple frame structure as described in the figure below will be calculated.

.. plot:: pybar_examples/quickstart_geom.py

Geometry
********

To build the model a :py:class:`model.Model` has to be created::

    # Initialize a Model instance of a 2D model
    m = pb.model(name='Model 1', dimensionality='2D')

The geometry of the problem can then be defined by means of :py:class:`nodes.Node`, which is conveniently wrapped in the method :py:meth:`model.Model2D.beam` of the class :py:class:`model.Model`::

    # Add nodes in the specified positions
    n1 = m.node(0, 0)
    n2 = m.node(0, 2000)
    n3 = m.node(2000, 2000)
    n4 = m.node(2000, 0)

Beam elements (:py:class:`elements.beam2d.Beam2D`) are created using a method of the class :py:class:`model.Model`::

    # Add Beam2D elements
    b1 = m.beam(n1, n2)
    b2 = m.beam(n2, n3)
    b3 = m.beam(n3, n4)

Material and cross-section
**************************

The material is defined by means of the :py:meth:`model.Model.material` method, which creates an instance of the class :py:class:`materials.Material`.
This is then assigned to a Section instance (:py:class:`sections.BeamSection`) using the :py:meth:`model.Model.beam_section` method::

    # Create a material instance
    steel = m.material(name='steel', data=(200e3, ), type='isotropic')
    # Create a beam section
    section_1 = m.beam_section(name='section 1', material=steel,
                               data=(32e2, 2356e4), type='general')

The above created **Section** now needs to be assigned to a **Beam** instance (:py:class:`elements.beam2d.Beam2D`)::


    # Assign the section to the beam elements
    b1.assign_section(section_1)
    b2.assign_section(section_1)
    b3.assign_section(section_1)


Applying loads and border conditions
************************************


PyBar supports the application of both point loads as well as distributed loads. For this, the methods :py:meth:`model.Model.load` and :py:meth:`elements.beam2d.distributed_load` are used.
The border conditions (BCs) are defined with the method :py:meth:`elements.beam2d.distributed_load`::

    # Add border conditions
    m.bc(node=n1, v1=0., v2=0., r3=0.)
    m.bc(node=n4, v1=0., v2=0.)

    # Add point Load
    m.load(node=n2, f2=-20e3)
    m.load(node=n3, f1=10e3)

    # Add distributed load
    b1.distributed_load(p1=-2, direction='y', coord_system='local')


Visualizing the model
*********************

A visual inspection of the model is crucial to easily spot problems in the model.
To see the current state of the model a :py:class:`plot.Display` instance has to be instantiated and a `Matplotlib <http://www.matplotlib.org>`_ axis has to be passed (this might change in the future)::

    # create matplotlib figure and axes
    import matplotlib.pyplot as plt
    fig = plt.figure(figsize=(6.,5.3.))
    ax = fig.add_subplot(111)
<commit_msg>Small fix<commit_after>Quick start
===========

.. currentmodule:: pybar

Loading the library
-------------------

To use **pybar** simply import the library as you would usually do::

    import pybar as pb

That's it! After this, you are ready to start building your model.

Building the model
------------------

A simple frame structure as described in the figure below will be calculated.

.. plot:: pybar_examples/quickstart_geom.py

Geometry
********

To build the model a :py:class:`model.Model` has to be created::

    # Initialize a Model instance of a 2D model
    m = pb.model(name='Model 1', dimensionality='2D')

The geometry of the problem can then be defined by means of :py:class:`nodes.Node`, which is conveniently wrapped in the method :py:meth:`model.Model2D.beam` of the class :py:class:`model.Model`::

    # Add nodes in the specified positions
    n1 = m.node(0, 0)
    n2 = m.node(0, 2000)
    n3 = m.node(2000, 2000)
    n4 = m.node(2000, 0)

Beam elements (:py:class:`elements.beam2d.Beam2D`) are created using a method of the class :py:class:`model.Model`::

    # Add Beam2D elements
    b1 = m.beam(n1, n2)
    b2 = m.beam(n2, n3)
    b3 = m.beam(n3, n4)

Material and cross-section
**************************

For this example, the material consist of a steel, with an modulus of elasticity (MOE) equals to 200GPa.
The cross-section of the beam is defined in a *general* way by giving both the area and moment of inertia
as a tuple (see :meth:`model.Model.beam_section` to understand how to pass different parameters).

+----------+---------+-------+
| Property | value   | units |
+==========+=========+=======+
| Area     | 3200    | mm^2  |
+----------+---------+-------+
| Inertia  | 23.56e6 | mm^4  |
+----------+---------+-------+

The material is defined by means of the :meth:`model.Model.material` method, which creates an instance of the class :class:`materials.Material`.
This is then assigned to a Section instance (:class:`sections.BeamSection`), using the :meth:`model.Model.beam_section` method and giving the
parameter ``type='general'``.::

    # Create a material instance
    steel = m.material(name='steel', data=(200e3, ), type='isotropic')
    # Create a beam section
    section_1 = m.beam_section(name='section 1', material=steel,
                               data=(32e2, 2356e4), type='general')

The above created **Section** now needs to be assigned to a **Beam** instance (:py:class:`elements.beam2d.Beam2D`)::


    # Assign the section to the beam elements
    b1.assign_section(section_1)
    b2.assign_section(section_1)
    b3.assign_section(section_1)


Applying loads and border conditions
************************************


PyBar supports the application of both point loads as well as distributed loads. For this, the methods :meth:`model.Model.load` and :meth:`elements.beam2d.distributed_load` are used.
The border conditions (BCs) are defined with the method :meth:`elements.beam2d.distributed_load`::

    # Add border conditions
    m.bc(node=n1, v1=0., v2=0., r3=0.)
    m.bc(node=n4, v1=0., v2=0.)

    # Add point Load
    m.load(node=n2, f2=-5e3)
    m.load(node=n3, f1=-10e3)

    # Add distributed load
    b1.distributed_load(p1=-2, direction='y', coord_system='local')


Visualizing the model
*********************

A visual inspection of the model is crucial to easily spot problems in the model.
To see the current state of the model a :class:`plot.Display` instance has to be instantiated and a `Matplotlib <http://www.matplotlib.org>`_ axis has to be passed (this might change in the future)::

    # create matplotlib figure and axes
    import matplotlib.pyplot as plt
    fig = plt.figure(figsize=(6.,5.3.))
    ax = fig.add_subplot(111)

{'fraction_non_alphanumeric': 0.1592485549132948, 'fraction_numerical': 0.029335260115606936, 'mean_word_length': 3.535386631716907, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '69493', 'n_tokens_mistral': 2288, 'n_tokens_neox': 2123, 'n_words': 747}