You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/components/variable_ported_objects.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -111,7 +111,7 @@ The automatic creation of input ports can be overridden: see the documentation o
111
111
112
112
In practice, there are only two reasons to specify ports:
113
113
114
-
1. In the case where not every variable needs to be exposed. This is useful when, for example, a second-order differential equation is being modelled by a system of first-order equations. For example, the pendulum equation $\ddot y = - \frac{g}{l} sin(y)$ can be written as the two first-order equations $\dot y = x$ and $\dot x = - \frac{g}{l} sin(y)$. In this case, we only need to expose the variable `y`. This can be done as follows:
114
+
1. In the case where not every variable needs to be exposed. This is useful when, for example, a second-order differential equation is being modelled by a system of first-order equations. For example, the pendulum equation $\ddot y = - \frac{g}{l} sin(y)$ can be written as the two first-order equations $\dot y = x$ and $\dot x = - \frac{g}{l} sin(y)$. In this case, we only need to expose the variable `y`. This can be done as follows:
There are many ways you can be involved in contributing to the development and maintenance of `psymple`.
6
+
7
+
- Help to find bugs or other issues, by adding a bug report to the [issues](https://github.com/casasglobal-org/psymple/issues) page.
8
+
- Help to edit and maintain the [documentation](https://casasglobal-org.github.io/psymple/) using issues or [pull requests](https://github.com/casasglobal-org/psymple/pulls).
9
+
- Develop new features, examples, documentation or bug fixes by creating pull requests.
10
+
- Get involved by helping to review open issues and pull requests.
11
+
- Report something you've done using `psymple`, discuss any big ideas, or simply let us know what you think using our [discussion board](https://github.com/casasglobal-org/psymple/discussions).
12
+
13
+
!!! tip "Credit where it is due"
14
+
15
+
Anyone who makes consistent and positive contributions, either directly or indirectly, will be offered an entry on our [Development Team](development_team.md) page.
16
+
17
+
18
+
## Code of conduct
19
+
20
+
`psymple` is an open-source project which we aim to turn into a community-driven modelling platform. We welcome anyone from all backgrounds and expertise levels to get involved with `psymple` to create a diverse, welcoming and productive space. We expect anyone contributing to our community to help us do this by following the following simple guidelines:
21
+
22
+
1.**Open by default**. As an open-source and open-access project, we also implement an open-by-default approach to questions, issues, discussions and contributions to promote productivity, efficiency and accuracy.
23
+
2.**Collaborative by nature**. The best solutions are found by engaging with those outside of your usual circles and comfort zone. We ask that you both listen to, and engage with, people with different backgrounds or views to your own to come up with the best outcomes.
24
+
3.**Think big and small**. This project has big ambitions to create impact for as many people as possible, but this requires both an eye for detail for components that make up this project. We ask that every change or addition to the codebase is done with both an eye for excellence and with a holistic view of the whole.
25
+
4.**Respect for all**. People will all levels of experience and knowledge use this project. Treat everyone with respect, empathy and sympathy, and assume that everyone has good intentions. Do not shy away from being critical, but back up everything with evidence, and never make it personal.
26
+
27
+
!!! failure "We will never tolerate:"
28
+
29
+
- Violent threats or language directed against another person.
30
+
- Sexist, racist, or otherwise discriminatory jokes, insults, material and language.
31
+
- Posting (or threatening to post) other people’s personally identifying information (“doxing”).
32
+
- Sharing private content, such as emails sent privately or non-publicly, or unlogged forums, such as IRC channel history, without the sender’s consent.
33
+
- Excessive profanity. In the context of modelling, there may be examples dealing with profane or sensitive content. This is never a reason to use associated language out of context. Never use swear words.
34
+
- Repeated harassment of others. For the avoidance of doubt, if someone asks you to stop, then stop.
35
+
- Advocating for, or encouraging, any of the above behaviour.
`psymple` is an open-source and open-access project which welcomes all contributions from all third parties. More information about how to contribute to `psymple` can be found on the [Community Guidelines](community_guidelines.md) page.
4
+
5
+
## Governance and steering
6
+
7
+
The package `psymple` is currently being produced under a collaboration between [CASAS Global](https://www.casasglobal.org/) and [IDEMS International](https://www.idems.international/). Members of both organisations form the current core governance and steering team. In addition to being involved in the day-to-day community of `psymple`, this team maintains a collective responsibility for the development, maintenance and direction of `psymple` and are able to:
8
+
9
+
- Make decisions about the overall scope, vision and direction of the project.
10
+
- Make decisions about strategic collaborations with other organizations or individuals.
11
+
- Make decisions about specific technical issues, features, bugs and pull requests. They are the primary mechanism of guiding the code review process and merging pull requests.
12
+
- Update policy documents such as this one.
13
+
- Make decisions when regular community discussion doesn’t produce consensus on an issue in a reasonable time frame.
14
+
15
+
More information about this team and their contributions an expertise can be found on the [Development Team](development_team.md) page.
16
+
17
+
## Code of conduct
18
+
19
+
Our current Code of conduct can be found [here](community_guidelines.md#code-of-conduct).
`psymple` has been developed using a broad range of expertise and contributions. This page recognises all consistent and positive contributions, both directly to the codebase and indirectly to the scope, direction and suitability of the package.
4
+
5
+
## Core governance and steering team
6
+
7
+
This is the current team who maintain a collective responsibility for the development, maintenance and direction of `psymple`, in alphabetical order of surname.
8
+
9
+
| Name | Organisation(s) | Contribution(s) | Years active |
|[Luigi Ponti](https://github.com/luisponti)| <ul><li>Research scientist, [ENEA](https://www.enea.it/en/)</li><li>Research fellow, [CASAS Global](https://casasglobal.org/)</li></ul> | <ul><li>Biological and ecosystem modelling</li><li>Github structures and management</li></ul> | 2023 + |
15
+
|[George Simmons](https://github.com/GJHSimmons)| Postdoctoral Impact Activation Fellow, [IDEMS International](https://www.idems.international/)| <ul><li>Code developer and maintainer</li><li>Applied category theory and collaborative modelling</li><li>Github structures and management</li></ul> | 2023 + |
16
+
|[David Stern](https://github.com/volloholic)| Director, [IDEMS International](https://www.idems.international/)| <ul><li>Applied category theory and collaborative modelling</li><li>Scalability and impact</li></ul> | 2023 + |
17
+
18
+
19
+
## Development and maintenance team
20
+
21
+
!!! info
22
+
23
+
Anyone who contributes consistently and positively to `psymple` will be offered a place here: see our [Community Guidelines](community_guidelines.md) for more information.
24
+
25
+
-[Georg Osang](https://github.com/geoo89) - Code developer and maintainer
26
+
-[Luigi Ponti](https://github.com/luisponti) - Github structures and management
27
+
-[George Simmons](https://github.com/GJHSimmons) - Code developer and maintainer
This page contains examples which go through the process of defining, parametrising and simulation systems in `psymple`.
4
+
5
+
It is recommended to go through these examples after covering, or with reference to, the material in the [user guide](../user_guide/getting_started.md), which has a bigger focus on the syntax and best practices of using `psymple`. Some of the examples covered in the user guide are covered here, and vice-versa.
6
+
7
+
These examples are arranged roughly in order of difficulty and complexity, with the later examples also providing less commentary on the implementation.
These examples show how to model _mixing problems_ in `psymple`. A mixing problem seeks to understand the evolution of a quantity of solvent in a solute, for example a chemical being mixed in a tank of water. These problems can be highly varied, for example solution can enter a tank at variable concentration or rate, or leave the tank at variable rate. Alternatively, several tanks can be connected together, with their solutions being pumped into each other.
4
+
5
+
These examples first consider the problem for a single tank, and then the problem for many arbitrarily linked tanks.
6
+
7
+
In all examples, the core assumption is that tanks are _well-mixed_, that is, the concentration of the solute is the same throughout the tank at any moment in time.
Copy file name to clipboardExpand all lines: docs/examples/mixing_problems/multiple_tanks.md
+36-16Lines changed: 36 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,10 @@
1
-
In the previous example, we considered a mixing problem with a single tank, which had an external flow in and an external flow out. Now we consider a mixing problem consisting of two or more tanks, each of which can have external flows in and out in the same manner as for the single tank, and which furthermore can have flows to and from other tanks in the system.
1
+
# Multiple tanks mixing problem
2
2
3
-
It will help to first specify the system data. In this case, we will create a system with \( n > 1 \) tanks, such that every tank has a flow in and flow out, plus a flow to and from every other tank. The following data can be freely altered to reduce the external flows and connections, if desired.
3
+
The previous example modelled a mixing problem with a single tank, which had an external flow in and an external flow out. This example considers a mixing problem consisting of two or more tanks, each of which can have external flows in and out, and which furthermore can have flows to and from other tanks in the system.
4
+
5
+
## System data
6
+
7
+
It will help to first specify the system data. The following data specifies a system of $2$ tanks which are fully interconnected, and each have external flows both in and out. This data can be freely altered to reflect different configurations and all the code in this example will automatically run.
4
8
5
9
```py title="system data"
6
10
# Number of tanks
@@ -24,9 +28,11 @@ pipes_in_id = [1, 2]
24
28
pipes_out_id = [1, 2]
25
29
```
26
30
27
-
If you followed through the single tank example, the following lists of pipes in and out are created in exactly the same way as there. We create pipes in for every tank in `pipes_in_id` and pipes out for every tank in `pipes_out_id`.
31
+
## Defining the flow components
28
32
29
-
```py
33
+
As for the [single tank example](single_tank.md#modelling-flows-in-psymple), a tank is defined as the aggregation of multiple variables representing inflows and outflows. The following lists of pipes in and out are created in exactly the same way for the single tank example, with pipes in for every tank in `pipes_in_id` and pipes out for every tank in `pipes_out_id`.
34
+
35
+
```py title="external pipes"
30
36
from psymple.build import VariablePortedObject
31
37
32
38
pipes_in = [
@@ -52,17 +58,17 @@ pipes_out = [
52
58
]
53
59
```
54
60
55
-
Next, we need to define connector pipes. These have four variables:
61
+
To connect two tanks, a connector pipe is required. These have four variables:
56
62
57
63
-`Q_in`, the amount of salt entering the pipe from a tank,
58
64
-`Q_out`, the amount of salt flowing into the next tank. Note that this has the same concentration
59
65
as for `Q_in`,
60
66
-`V_in`, the volume of water entering the pipe from the tank,
61
67
-`V_out`, the volume of water exiting the pipe into the next tank.
62
68
63
-
We create a connector pipe for every pair in `link_pipes_id`.
69
+
A connector pipe is defined for every pair in `link_pipes_id`.
64
70
65
-
```py
71
+
```py title="connector pipes"
66
72
connectors = [
67
73
VariablePortedObject(
68
74
name=f"pipe_{i}_{j}",
@@ -77,11 +83,9 @@ connectors = [
77
83
]
78
84
```
79
85
80
-
Now we just need to define our system of tanks. Compared to the single tank example, the children, variable ports and input ports are exactly the same (just one for each tank, if it was specified), except for additionally the specification of the flow rates `rate_i_j` of the connector pipes as additional input ports.
81
-
82
-
The directed wires simply connect the rates at the input ports to the correct pipes.
86
+
## Defining the system
83
87
84
-
The only thing which becomes more complicated is the aggregation of the variables. Each tank `i`, and therefore each variable `Q_i` (and `V_i`), can have:
88
+
The system is defined by variables `Q_1`,...,`Q_n` and `V_1`,...,`V_n` representing the mass and volume in each of the $n$ tanks. This is done in an analogous way to the single tank example, where the only thing which becomes more complicated is the aggregation of the variables. Each tank `i`, and therefore each variable `Q_i` (and `V_i`), can have:
The following code sets up a simulation in which for $t<50$>, there are flows of $10\text{l/s}$ (from tank 2) and $4 \text{l/s}$ (external) into tank 1 and flows of $3\text{l/s}$ (to tank 2) and $11\text{l/s}$ (external) out. Similarly, tank 2 has flows in of $3\text{l/s}$ (from tank 1) and $7\text{l/s}$ (external) and flows out of $10\text{l/s}$ (to tank 1).
144
+
145
+
The external concentration of the fluid entering tank 1 is $0.5\text{g/l}$ and for tank 2 only pure water is added.
146
+
147
+
The total amount of solution in each tank will remain constant for $t<50$. At $t=50$ the external supply to tank 1 is turned off so that the volume of tank 1 will start to drain.
0 commit comments