> For the complete documentation index, see [llms.txt](https://tlcfem.gitbook.io/suanpan-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tlcfem.gitbook.io/suanpan-manual/material/material1d/degradation/customstressdegradation.md).

# CustomStressDegradation

Stress History Based Degradation With Custom Rules

This model implements the [universal damage model](/suanpan-manual/material/material1d/degradation/degradation.md) assuming the degradation factor depends on the stress history.

## Syntax

```
material CustomStressDegradation (1) (2) (3) [4]
# (1) int, unique material tag
# (2) int, host intact material tag
# (3) int, tension degradation expression tag
# [4] int, compression degradation expression tag, default: (3)
```

## Remarks

It is possible to assign different degradation evolution rules for tension and compression.

The degradation expression shall take one scalar input and return a vector of two scalars, of which the first is the degradation factor while the second is the derivative of the degradation factor with respect to the input.

The degradations for positive/negative stresses are defined separately.

$$
D\_{pos}=D\_{pos}(\bar{\sigma}*{max}),\quad
D*{neg}=D\_{neg}(\bar{\sigma}\_{min}).
$$

In which $$\bar{\sigma}*{max}$$ is the maximum stress (positive) of the whole loading history, and $$\bar{\sigma}*{min}$$ is the minimum stress (negative) of the whole loading history.

## Example

To use this model, expressions of degradation evolution rules must be defined first. Assuming the degradation is an exponential function, and will be activated when the effective stress is larger than 20,

$$
D=\exp(-(\bar{\sigma}-20)/20),
$$

the corresponding derivative is then

$$
\dfrac{\mathrm{d}D}{\mathrm{d}\bar{\sigma}}=-\dfrac{1}{20}\exp(-(\bar{\sigma}-20)/20).
$$

One can then define the expression in a plain text file as follows.

```
// file: exp_t
if(x>20){
	y[0]:=exp((-x+20)/20);
	y[1]:=-y[0]/20;
}else{
	y[0]:=1.;
	y[1]:=0.;
}
```

To use it, one shall use the [`SimpleVector`](/suanpan-manual/command-collection/define/expression.md) expression.

```
expression SimpleVector 1 x y|2 exp_t
```

Here we use $$x$$ as the input ($$\bar{\sigma}$$) and $$y\[0]$$ as the degradation ($$D$$), $$y\[1]$$ as the derivative ($$\dfrac{\mathrm{d}D}{\mathrm{d}\bar{\sigma}}$$).

### Same Degradation for Tension and Compression

We use an elastic host material for demonstration.

```
material Elastic1D 1 1000
expression SimpleVector 1 x y|2 exp_t
material CustomStressDegradation 2 1 1
materialTest1D 2 1E-3 10 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 60
```

![example one](https://1124082496-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEquxr3H9WpPg4iPvT2mB%2Fuploads%2Fgit-blob-1e712d6ffcd321fcc8b6f79166f8637ce253fe85%2FCSD.EX1.svg?alt=media)

### Different Degradation for Tension and Compression

We can define a different rule for compression.

```
// file: exp_c
if(x<-10){
	y[0]:=exp((x+10)/30);
	y[1]:=y[0]/30;
}else{
	y[0]:=1.;
	y[1]:=0.;
}
```

```
material Elastic1D 1 1000
expression SimpleVector 1 x y|2 exp_t
expression SimpleVector 2 x y|2 exp_c
material CustomStressDegradation 2 1 1 2
materialTest1D 2 1E-3 10 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 60
```

![example two](https://1124082496-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEquxr3H9WpPg4iPvT2mB%2Fuploads%2Fgit-blob-430dd3352ae1581ea30c628f9d3af5bd8a044472%2FCSD.EX2.svg?alt=media)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://tlcfem.gitbook.io/suanpan-manual/material/material1d/degradation/customstressdegradation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
