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 2 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
82 changes: 60 additions & 22 deletions user/preprocess/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ 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.txt",
"xvalues": [],
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 setting a file, you shouldn't need x and fx values

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

"fxvalues": []
}
],
"analysis": {
Expand Down Expand Up @@ -371,31 +378,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 +548,55 @@ 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)

### ASCII Math Functions
Math functions can also be specified through an ASCII file, and this is useful when it is rather long such that can be used to define time history of a dynamic earthquake ground motion. The JSON configuration for the math function is:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Math functions can also be specified through an ASCII file, and this is useful when it is rather long such that can be used to define time history of a dynamic earthquake ground motion. The JSON configuration for the math function is:
Math functions can also be specified through an ASCII 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.txt",
"xvalues": [],
"fxvalues": []
}
]
```

Math function can be specified in the following format:

```
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.

Can we go csv instead of tab separated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do so. Will change the main PR first

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).