# SETUP -----------------------------------------------------------------------

import lamana as la

# For plotting in Jupyter
%matplotlib inline                                         

# Build dicts for loading parameters and material properties 
load_params = {
    'P_a': 1,                                              # applied load 
    'R': 12e-3,                                            # specimen radius
    'a': 7.5e-3,                                           # support radius 
    'p': 4,                                                # points/layer
    'r': 2e-4,                                             # radial distance from center loading
}

mat_props = {
    'HA': [5.2e10, 0.25],                                  # modulus, Poissions ratio
    'PSu': [2.7e9, 0.33],            
}

# Build a list of geometry strings.
# Layer convention: 'outer - [{inner...-...}_i] - middle'
geos1 = ['400-400-400', '400-200-800', '400-350-500']      # eq. total thickness
geos2 = ['400-[400]-400', '400-[200,100]-800']             # eq. outer thickness 
#------------------------------------------------------------------------------

"""
Explanation: Getting Started
If you have already looked through the quick view section and want make one of those plots, this guide will assist you.
Jupyter and LamAna (recommended)
LamAna was developed with visualization in mind.  
LamAna works best with the Jupter Notebook 4.0+.  The Jupyter Notebook is a powerful, browswer-based analytical tool that integrates with many computer languages and runs computations in separate cells .  We use Jupyter and Python to make plots using a matplotlib backend.
If you installed Anaconda, you have Jupyter installed already.  Simply run, open a new notebook and import LamAna:
&gt; jupyter notebook


LamAna from Commandline
If visualization is not important to you, you can alternatively run calcuations and export data from the commandline.  You can invoke either python or ipython for and interactive prompt.

We will now explore how the user can input data and generate plots using the distributions module.
User Setup
First we must input loading parameters and material properties.  Secondly, we must invoke a selected laminate theory.  The former requires knowlege of the specimen dimensions, the materials properties and loading configuration.  For illustration, an schematic of laminate loading parameters is provided below.

A table is provided defining the illustrated parameters.  These loading parameters are coded in a Python dictionary called load_params. 
| Parameter | Units (SI) | Definition |
| :-------: | :--------: | :--------- |
| P | N | applied load |
| R | m | specimen radius | 
| a | m | support radius |
| b | m | piston radius |
| r | m | radial distance from central loading |
| p | - | graphical points or DataFrame rows per layer |
User Defined Parameters
Sample code is provided for setting up geometric dimensions, loading parameters and material properties.
End of explanation
"""


case1 = la.distributions.Case(load_params, mat_props)      # instantiate
case1.apply(geos1, model='Wilson_LT')                      # apply 
case1.plot()                                               # plot 

"""
Explanation: Generate Data in 3 Lines
With the loading and material information, we can make stress distribution plots to define (reusable) test cases by implementing 3 simple steps. 

Instantiate a Feature object with loading and material parameters. This makes a user Case object. 
apply() a laminate theory model
plot() the Case

Within seconds, you can now build a case and simultaneiously plot stress distributions for an indefinite number of laminates that vary in compostion and dimension.
End of explanation
"""


