Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for math function #53

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 57 additions & 22 deletions user/preprocess/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ The CB-Geo MPM code uses a `JSON` file for input configuration.
"type": "Linear",
"xvalues": [0.0, 0.5, 1.0],
"fxvalues": [0.0, 1.0, 1.0]
},
{
"id": 1,
"type": "Linear",
"file": "math-function.csv"
}
],
"analysis": {
Expand Down Expand Up @@ -371,31 +376,10 @@ A load without a math function will be applied as a static load. Use math functi

Both `concentrated_nodal_forces` and `particle_surfacce_traction` use [`entity_sets`](./entity_sets) to apply forces on a set of nodes and particles. The loading can be time-varying. The time-variation of the load can be specified using a math function. Setting the `nset_id` or `pset_id` to `-1` will apply the loading to all the nodes and particles.

### Math functions

Math functions are useful to define how a certain load varies with time. A typical math function is shown below.

```
"math_functions": [
{
"id": 0,
"type": "Linear",
"xvalues": [0.0, 0.5, 1.0, 1.5],
"fxvalues": [0.0, 1.0, 1.0, 0.0],
}
]
```

This is a linear function with x and corresponding f(x) values. The function varies as shown in the figure. If used with a traction, the value of traction at different times will be computed as the defined math function.

![x_fx](x_fx.png)


### ASCII loading conditions
> Warning: ASCII loading conditions do not support math functions

Loading conditions on the nodes can also be specified through an ASCII file. The JSON configuration for the boundary
condition is:
Loading conditions on the nodes can also be specified through an ASCII file. The JSON configuration for the loading condition is:

```
"external_loading_conditions": {
Expand Down Expand Up @@ -562,3 +546,54 @@ where,

`f_i` is the friction coefficient.

## Math functions

Math functions are useful to define how a certain load varies with time. A typical math function is shown below.

```
"math_functions": [
{
"id": 0,
"type": "Linear",
"xvalues": [0.0, 0.5, 1.0, 1.5],
"fxvalues": [0.0, 1.0, 1.0, 0.0],
}
]
```

This is a linear function with x and corresponding f(x) values. The function varies as shown in the figure. If used with a traction, the value of traction at different times will be computed as the defined math function.

![x_fx](x_fx.png)

### CSV Math Functions
Math functions can also be specified through a CSV file, and this is useful when they are rather long such as math functions used to define time history of a dynamic earthquake ground motion. The JSON configuration for the math function is:

```
"math_functions": [
{
"id": 1,
"type": "Linear",
"file": "math-function.csv"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is inconsistency in naming, here it's called file and above csvfile, please use file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}
]
```

Math function can be specified in the following format:

```
#xvalue, fxvalue
x_0, fx_0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are using a csv parser, could we have a header line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

x_1, fx_1,
..., ...,
..., ...,
x_i, fx_i,
..., ...,
..., ...,
x_n, fx_n
```

where,

`x_i` is the independent varirable x,

`fx_i` is the dependent variable f(x).