Non Linear Solver for Mechanical Analyses¶
- class code_aster.Solvers.IterationSolver.iteration_solver.BaseIterationSolver[source]¶
Bases:
ABC,ContextMixin,DispatcherMixinSolves a step, loops on iterations.
- classmethod factory(context)[source]¶
Factory that creates the appropriate object.
- Parameters:
context (Context) – Context of the problem.
- Returns:
New object.
- Return type:
instance
- property matr_prediction¶
Type of prediction matrix to be used.
- Type:
str
- property update_matr_incr¶
Number of increments between updating matrix.
- Type:
int
- setLoggingManager(logManager)[source]¶
Assign the logging manager.
- Parameters:
logManager (LoggingManager) – Logging manager.
- property matrix_type¶
Type of the matrix to be currently used.
- Type:
str
- class code_aster.Solvers.IterationSolver.newton_solver.NewtonSolver[source]¶
Bases:
BaseIterationSolver,EventSourceSolves a step, loops on iterations.
- classmethod builder(context)[source]¶
Builder of NewtonSolver object.
- Parameters:
context (Context) – Context of the problem.
- Returns:
New object.
- Return type:
instance
- update(deltaU, resi_fields=None, callback=None)[source]¶
Update the physical state.
- Parameters:
deltaU (FieldOnNodes) – Displacement increment.
resi_fields (dict of FieldOnNodes) – Fields of residual values
- _resetMatrix()[source]¶
Reset matrix if needed
- Parameters:
current_incr (int) – index of the current increment
- solve(current_matrix, callback=None)[source]¶
Solve a step.
- Raises:
*ConvergenceError* exception in case of error. –
- solve_iteration(matrix_type, matrix=None, force=False)[source]¶
Solve the iteration.
- Parameters:
matrix_type (str) – type of matrix used.
matrix (AssemblyMatrixDisplacementReal, optional) – Stiffness matrix to be reused.
- Returns:
Tuple with incremental primal, Jacobian matrix used (if computed).
- Return type:
- _compute_primal_incr(residuals, jacobian, force, scaling)[source]¶
Solve the linear system to obtain the current solution increment
- _get_jacobian_iteration(matrix, matrix_type)[source]¶
Obtain the Jacobian matric (recompute or use the one provided)
- Parameters:
matrix_type (str) – type of matrix used.
matrix (AssemblyMatrixDisplacementReal, optional) – Stiffness matrix to be reused.
- Returns:
Stiffness matrix to use in the current iteration
- Return type:
jacobian (AssemblyMatrixDisplacementReal)
- class code_aster.Solvers.IterationSolver.convergence_manager.ConvergenceManager[source]¶
Bases:
ContextMixinObject that decides about the convergence status.
- class Parameter(reference)[source]¶
Bases:
objectA parameter to be checked for convergence.
- Parameters:
reference (float|int) – Reference value.
- classmethod factory(name, reference)[source]¶
Build a parameter object.
- Parameters:
name (str) – Parameter name.
reference (float|int) – Reference value.
- isSet()[source]¶
Tell if the parameter value has been assigned.
- Returns:
True if the parameter has a value, False if not.
- Return type:
bool
- minSet()[source]¶
Tell if a minimal value has been assigned.
- Returns:
True if the parameter has a minimum, False if not.
- Return type:
bool
- hasRef()[source]¶
Tell if a reference value is defined for the parameter.
- Returns:
True if the parameter has a reference value, False if not.
- Return type:
bool
- property reference¶
Reference value of the parameter.
- Type:
float|int
- property value¶
Current value of the parameter.
- Type:
float|int
- property minValue¶
Current minimal value of the parameter.
- Type:
float|int
- class ResidualParameter(reference)[source]¶
Bases:
ParameterType of Parameter for a residual.
- Parameters:
name (str) – Parameter name.
reference (float|int) – Reference value.
- match(pos=0, endpos=9223372036854775807)¶
Scan through string looking for a match, and return a corresponding match object instance.
Return None if no position in the string matches.
- class IterationParameter(reference)[source]¶
Bases:
ParameterType of Parameter for a number of iteration.
- Parameters:
name (str) – Parameter name.
reference (float|int) – Reference value.
- match(pos=0, endpos=9223372036854775807)¶
Scan through string looking for a match, and return a corresponding match object instance.
Return None if no position in the string matches.
- class ReferenceParameter(reference)[source]¶
Bases:
Parameterreerences for RESI_REFE_RELA
- match(pos=0, endpos=9223372036854775807)¶
Scan through string looking for a match, and return a corresponding match object instance.
Return None if no position in the string matches.
- classmethod builder(context)[source]¶
Default builder for
ContextMixinobject. Should be subclassed for non trivial constructor.- Parameters:
context (Context) – Context of the problem.
- Returns:
New object.
- Return type:
instance
- initialize(*mandatory)[source]¶
Initialize the object for a new iteration.
Mandatory parameters must be defined before checking their convergency (here they are assigned to a negative value, not converged).
- Parameters:
mandatory (tuple) – Name of parameters that are mandatory.
- hasResidual()[source]¶
Tell if there is at least one residual convergence parameter.
- Returns:
True if at least one parameter is defined, False otherwise.
- Return type:
bool
- setdefault(name, reference=UNDEF)[source]¶
Add a convergence parameter if it does not yet exist.
- Parameters:
name (str) – Name of the parameter.
reference (float) – Reference value of the parameter.
- Returns:
The existing parameter if it already exists or a newly created one.
- Return type:
Parameter
- get(name)[source]¶
Return the value of a convergence parameter.
- Parameters:
name (str) – Name of the parameter.
- Returns:
Parameter value or undef it the parameter is not defined.
- Return type:
float|int
- getParameters()[source]¶
Return a copy of the parameters with their current values.
- Returns:
Dict of parameters
- Return type:
dict
- getDirichletResidual(residual)[source]¶
Return the residual with Dirichlet imposed values.
- Parameters:
residual (FieldOnNodesReal) – Residual.
- Returns:
Residual changed in place.
- Return type:
- getRelativeScaling(residuals)[source]¶
Returns the scaling factor to compute the relative error
- Parameters:
residuals (Residuals) – Collections of residuals.
- Returns:
scaling factor.
- Return type:
float
- evalNormResidual(residuals)[source]¶
Evaluate global residual.
- Parameters:
residuals (Residuals) – Collections of residuals.
- evalGeometricResidual(displ_delta)[source]¶
Evaluate geometric residual.
- Parameters:
displ_dela (FieldOnNodesReal) – variation of displacement.
- isConverged()[source]¶
Tell if the convergence parameters are verified.
- Returns:
True if converged, False otherwise.
- Return type:
bool
- class code_aster.Solvers.IterationSolver.line_search.LineSearchType(value)[source]¶
Bases:
IntFlagLine Search types.
- class code_aster.Solvers.IterationSolver.line_search.BaseLineSearch[source]¶
Bases:
ABC,ContextMixinBase for line search methods
- classmethod factory(context)[source]¶
Factory that creates the appropriate object.
- Parameters:
context (Context) – Context of the problem.
- Returns:
New object.
- Return type:
BaseLineSearch
- abstract solve(solution, scaling=1.0)[source]¶
Apply linear search for mechanical problems.
- Parameters:
solution (FieldOnNodes) – Displacement solution.
scaling (float) – Scaling factor for Lagrange multipliers (default: 1.0).
- Returns:
Accelerated solution by linear search.
- Return type:
FieldOnNodes
- class code_aster.Solvers.IterationSolver.line_search.SecantLineSearch[source]¶
Bases:
BaseLineSearchLine search for CORDE & MIXTE methods.
Useful objects used to build operators.
- class code_aster.Solvers.Basics.bases.ProblemType(value)[source]¶
Bases:
IntFlagTypes of physical problems.
- class code_aster.Solvers.Basics.bases.DispatcherMixin[source]¶
Bases:
objectMixin class that provides a factory depending on the type of physical problem.
- class code_aster.Solvers.Basics.bases.Observer[source]¶
Bases:
ABCThe Observer interface declares the notify method, used by events.
- abstract notify(event)[source]¶
Receive notification from event.
- Parameters:
event (EventSource) – Object that sends the notification.
- class code_aster.Solvers.Basics.bases.EventId(value)[source]¶
Bases:
IntFlagIdentifiers of EventSource objects.
- class code_aster.Solvers.Basics.bases.EventSource[source]¶
Bases:
ABCThe EventSource interface declares a set of methods for managing observers.
- add_observer(observer)[source]¶
Attach an observer to the event.
- Parameters:
observer (Observer) – Observer object to be added.
Base objects used to solve generic non linear problems.
- class code_aster.Solvers.Basics.context.Context[source]
Bases:
objectObject that stores the objects required by a
NonLinearOperator.It only stores objects that are shared at different levels of the algorithm. Objects only used by one stage/object should be created there. If different objects should be created at each timestep for example, they should not be here.
- problem
PhysicalProblemobject
- state
PhysicalStateobject
- result
Resultobject (NonLinearResult,ThermalResult,DryingResult)
- problem_type
ProblemTypeenum value
- keywords
Part of the user keywords
- oper
BaseOperatorsobject
- stepper
TimeStepperobject
- contact
ContactManagerobject
- linear_solver
LinearSolverobject
- class KeywordsStore(keywords)[source]
Bases:
objectContainer that stores and gives access to some user keywords.
- __init__(keywords)[source]
- __getitem__(keyword)[source]
Return a keyword value.
- Parameters:
keyword (str) – Simple keyword.
- Returns:
Keyword value.
- Return type:
misc
- get(keyword, parameter=None, default=None)[source]
Return a keyword value.
- Parameters:
keyword (str) – Simple or factor keyword.
parameter (str|None) – Simple keyword under the factor keyword, or None.
default (misc) – Default value if the keyword is undefined.
- Returns:
Keyword value.
- Return type:
misc
- __init__()[source]
- check()[source]
Check for required/optional attributes.
- property problem_type
Attribute that holds the type of problem.
- Type:
- property keywords
Attribute that holds the keywords object.
- Type:
Dict
- get_keyword(keyword, parameter=None, default=None)[source]
“Return a keyword value.
- Parameters:
keyword (str) – Simple or factor keyword.
parameter (str|None) – Simple keyword under the factor keyword, or None.
default (misc) – Default value if the keyword is undefined.
- Returns:
Keyword value.
- Return type:
misc
- property problem
current problem description.
- Type:
- property state
current state.
- Type:
- property result
Attribute that holds the result object.
- Type:
- property stepper
Attribute that holds the time stepper.
- Type:
TimeStepper
- property oper
Object that adapts operators for each type of problem.
- Type:
Operators
- property contact
Object to solve contact conditions
- Type:
ContactManager
- property linear_solver
Attribute that holds the linear solver.
- Type:
- code_aster.Solvers.Basics.context.check_access(alt=None)[source]
Decorator to wrap TestCase methods by calling writeResult
- class code_aster.Solvers.Basics.context.ContextMixin[source]
Bases:
objectMixin object that wraps access to the objects of Context.
- problem
PhysicalProblemobject
- state
PhysicalStateobject
- result
Resultobject (NonLinearResult,ThermalResult,DryingResult)
- problem_type
ProblemTypeenum value
- keywords
Part of the user keywords
- oper
BaseOperatorsobject
- contact
ContactManagerobject
- linear_solver
LinearSolverobject
- classmethod builder(context)[source]
Default builder for
ContextMixinobject. Should be subclassed for non trivial constructor.- Parameters:
context (Context) – Context of the problem.
- Returns:
New object.
- Return type:
instance
- __init__()[source]
- property context
Context attached to the object.
- Type:
Data
- property problem_type
Attribute that holds the type of problem.
- Type:
- property keywords
Attribute that holds the keywords object.
- Type:
Dict
- get_keyword(keyword, parameter=None, default=None)[source]
“Return a keyword value.
- Parameters:
keyword (str) – Simple or factor keyword.
parameter (str|None) – Simple keyword under the factor keyword, or None.
default (misc) – Default value if the keyword is undefined.
- Returns:
Keyword value.
- Return type:
misc
- property problem
current problem description.
- Type:
- property state
current state.
- Type:
- property result
Attribute that holds the result object.
- Type:
- property stepper
Attribute that holds the time stepper.
- Type:
TimeStepper
- property oper
Object that adapts operators for each type of problem.
- Type:
Operators
- property contact
Object to solve contact conditions
- Type:
ContactManager
- property linear_solver
Attribute that holds the linear solver.
- Type:
- code_aster.Solvers.Basics.physical_state.get_all_subclasses(cls)[source]¶
Return all subclasses of ‘cls’ recursively.
- class code_aster.Solvers.Basics.physical_state.PhysicalState(pb_type, size=1)[source]¶
Bases:
ObserverThis object represents a Physical State of the model.
Actually, it stores a stack of physical states and works as an adapter on the current state. Only the current state, the working one, has setters and so is writable. All other states on the stack are read-only.
- class State[source]¶
Bases:
ABCRepresents an elementary physical state (private).
For the primal fields, one stores the field at the beginning of the step and its increment. They are accessed with U and eventually dU, d2U. The dual field is accessed with S (stress in mechanics) or Phi (heat flux in thermics) properties (value at t+dt). The other fields are accessed by name (value at t+dt).
- classmethod factory(pb_type: ProblemType)[source]¶
Create a new State object of ProblemType.
- abstract property U¶
Attribute that holds the primal unknown.
- Type:
U
- property time_prev¶
Previous time.
- Type:
float
- property time_curr¶
Current time.
- Type:
float
- property time_step¶
Time step.
- Type:
float
- property U_t¶
Primal field at previous time.
- Type:
- property deltaU¶
Primal increment.
- Type:
- property fields_prev¶
Dictionary of previous fields.
- Type:
dict
- property fields_step¶
Dictionary of fields steps.
- Type:
dict
- property dual¶
Dual field.
- Type:
- property internVar¶
Internal state variables.
- Type:
- property externVar¶
External state variables.
- Type:
- copy(other)[source]¶
Copy the content of an object into the current one.
- Parameters:
other (PhysicalState.State) – Object to be copied.
- Returns:
Current object.
- Return type:
- swap(other)[source]¶
Swap the content of an object with the current one.
- Parameters:
other (PhysicalState.State) – Object to be swaped.
- class StateMecaStat[source]¶
Bases:
State- property U¶
Attribute that holds the displacement field.
- Type:
U
- class StateMecaDyna[source]¶
Bases:
StateMecaStat- property dU¶
Attribute that holds the derivative of displacement field.
- Type:
dU
- property d2U¶
Attribute that holds the second derivative of displacement field.
- Type:
U
- class StateThermal[source]¶
Bases:
StateMecaStat
- copy(other)[source]¶
Copy the content of an object into the current one.
- Parameters:
other (PhysicalState) – Object to be copied.
- Returns:
Current object.
- Return type:
- swap(other)[source]¶
Swap the content of the physical state.
- Parameters:
other (PhysicalState) – the physical state to be swaped.
- getState(index=0)[source]¶
Return a physical state by index (relative position).
- Parameters:
index (int) – 0 means the current one, -1 the previous one and so on.
- Returns:
physical state.
- Return type:
- property pb_type¶
The type of the physical problem
- Type:
- property current¶
The current physical state, the working one.
- Type:
- property time_prev¶
Previous time.
- Type:
float
- property time_curr¶
Current time.
- Type:
float
- property time_step¶
Time step.
- Type:
float
- property U_t¶
Primal field at previous time.
- Type:
- property U¶
Primal field at current time.
- Type:
- property deltaU¶
Primal increment.
- Type:
- property dual¶
Dual field.
- Type:
- property stress¶
Dual field.
- Type:
- property phi¶
Dual field.
- Type:
- property internVar¶
Internal state variables.
- Type:
- property externVar¶
External state variables.
- Type:
- set(key, field)[source]¶
Assign a field at the given key.
- Parameters:
field (FieldOnCellsReal) – Field
- getCurrentDelta()[source]¶
Return the delta for the current state between it has been stashed.
- Returns:
Delta between states as returned by py:method:asdict.
- Return type:
dict
- getDeltaBetweenStates(index1, index2)[source]¶
Return the delta between two states.
The states are extracted using getState(index). It returns the difference getState(index2) - getState(index1).
- Parameters:
index1 (int) – Index of the first state.
index2 (int) – Index of the second state.
- Returns:
Delta between states as returned by py:method:asdict.
- Return type:
dict
- static createPrimal(phys_pb, value=0.0)[source]¶
Create primal field with a given value
- Parameters:
phys_pb (PhysicalProblem) – Physical problem
value (Union[float, dict]) – value to set everywhere
- Returns:
primal field with a given value (DEPL|TEMP)
- Return type:
FieldOnNodes
- static createFieldOnCells(phys_pb, localization, quantity, value=0.0)[source]¶
Create a field with a given value
- Parameters:
phys_pb (PhysicalProblem) – Physical problem
localization (str) – localization of the field to create (ELNO, ELEM, ELGA)
quantity (str) – type of the field to create (ex: SIEF_R, …)
value (float) – value to set everywhere
- Returns:
field with a given value of type “type”
- Return type:
FieldOnCells
- static createDual(phys_pb, value)[source]¶
Create the dual field with a given value
- Parameters:
phys_pb (PhysicalProblem) – Physical problem
value (float) – value to set everywhere
- Returns:
Stress field with a given value (SIEF_ELGA/FLUX_ELGA)
- Return type:
FieldOnCells
- static createInternalVariablesNext(phys_pb, value)[source]¶
Create internal state variables field with a given value
- Parameters:
phys_pb (PhysicalProblem) – Physical problem
value (float) – value to set everywhere
- Returns:
internal state variables field with a given value (VARI_ELGA)
- Return type:
FieldOnCells
- static createTimeField(phys_pb, value)[source]¶
Create time field with a given value
- Parameters:
phys_pb (PhysicalProblem) – Physical problem
value (float) – value to set everywhere
- Returns:
time field with a given value
- Return type:
- zeroInitialState(phys_pb)[source]¶
Initialize with zero initial state
- Parameters:
phys_pb (PhysicalProblem) – Physical problem
- class code_aster.Solvers.Basics.residual.Residuals[source]¶
Bases:
objectContainer to store intermediate field.
- resi¶
Global residual.
- Type:
- resi_int¶
Internal residual.
- Type:
- resi_ext¶
External residual.
- Type:
- resi_dual¶
Dirichlet reactions.
- Type:
- resi_stress¶
Internal forces.
- Type:
- resi_cont¶
Contact residual.
- Type:
- resi_mass¶
Inertial residual.
- Type:
- class code_aster.Solvers.Basics.logging_manager.LoggingManager[source]¶
Bases:
objectObject that decides about the logging.
- addConvTableColumn(column)[source]¶
Add a colum to the table
- Arguements:
column[str]: title of the column