# Generating a study

**Generate study from scenario (beta)** writes a runnable code_aster study, a `.comm` and a matching `.export`, from a form with a live preview. Open it from the sidebar's Quick actions or the Command Palette.

## 1. Pick a mesh

A file dialog asks for the MED mesh ("Select the MED mesh for the study"), starting from the active MED file if there is one. The form then reads the mesh groups ("Reading mesh groups…") and offers them in every group field, filtered by kind. You can also type group names, separated by commas. If the groups cannot be read (an incomplete file, or element types the extension does not read), a banner says so and you type them by hand.

The mesh can be changed later with **Browse…** in the Output section.

## 2. Fill in the form

**Analysis scenario**

- Linear elastic static analysis (`MECA_STATIQUE`)
- Nonlinear static analysis (`STAT_NON_LINE`)
- Modal analysis (`CALC_MODES`)

**Modelization**: `3D`, `D_PLAN` (plane strain), `C_PLAN` (plane stress), `AXIS` (axisymmetric), `DKT` (shells) or `POU_D_T` (beams).

**Material**: a preset (Steel: E 210000, NU 0.3, RHO 7800; Aluminum: 70000, 0.33, 2700; Concrete: 30000, 0.2, 2400) or Custom, with Young's modulus (E) and Poisson's ratio (NU). The modal scenario adds Density (RHO). The nonlinear scenario adds Yield stress (SY) and Hardening (D_SIGM_EPSI) for a von Mises isotropic hardening law.

**Material assignment groups**: where the material applies. Empty means the whole mesh.

**Shell properties** (`DKT`): groups and Thickness (EPAIS). **Beam properties** (`POU_D_T`): groups and a rectangular section (Section HY, Section HZ). Both generate an `AFFE_CARA_ELEM` block passed to the solver.

**Boundary condition**: the constrained groups and the constrained degrees of freedom, set to 0 (`DX`, `DY`, `DZ`, plus `DRX`, `DRY`, `DRZ` for shells and beams, `DX`, `DY` in 2D). Element groups and node groups go to `GROUP_MA` and `GROUP_NO`.

**Load** (static scenarios): pressure (`PRES_REP`), nodal force (`FORCE_NODALE`), face force (`FORCE_FACE`), edge force (`FORCE_ARETE`) or gravity (`PESANTEUR`), on chosen groups. Forces act along Z.

**Number of modes** (modal scenario).

**Output**: the study name (letters, digits and `_`, `case` by default), the mesh, and **Copy mesh into the study folder**.

Defaults: E 210000, NU 0.3, RHO 7800, SY 250, D_SIGM_EPSI 2000, thickness 0.01, sections 0.1 × 0.05, pressure 1000, 10 modes.

The **Preview** pane shows the `.comm` and `.export` as they will be written, and updates as you edit.

## 3. Generate

The study is written to a `<name>/` folder **next to the mesh**. If the folder exists, you are asked before its study files are overwritten. Both files open, the `.comm` in front.

By default the mesh is copied into the study folder. Untick **Copy mesh into the study folder** to reference it from the parent folder instead (`F mmed ../mesh.med D 20`), so several studies share one mesh.

## What is generated

The `.comm` starts with `DEBUT(CODE=_F(NIV_PUB_WEB="INTERNET"), LANG="EN")` and contains the mesh reading, model, material, element characteristics, boundary conditions and loads, then:

- static scenarios: the solve, then `CALC_CHAMP` for `SIGM_ELNO` and `SIEQ_ELNO`;
- nonlinear: a load ramp from 0 to 1 in 10 steps with a tangent Newton (`RESI_GLOB_RELA=1e-6`, `ITER_GLOB_MAXI=20`);
- modal: assembled stiffness and mass matrices and `CALC_MODES` with `OPTION="PLUS_PETITE"`;
- results written to MED on unit 80 with `IMPR_RESU`.

The `.export` has the default parameters of a new export file (`P time_limit 300`, `P memory_limit 1024`, `P ncpus 1`, `P mpi_nbcpu 1`, `P mpi_nbnoeud 1`), and declares `F comm <name>.comm D 1`, `F mmed <mesh> D 20`, `F mess <name>.mess R 6` and `F rmed <name>.rmed R 80`. Change the parameters with the [export form](/export-files).

The result is a starting point: refine it with the [editor features](/comm-files) and [validate it](/validation) before running.
