{"id":23003117,"url":"https://github.com/heiderjeffer/equilibrium-analysis-in-computational-science","last_synced_at":"2025-06-18T08:38:17.339Z","repository":{"id":248511405,"uuid":"828897847","full_name":"HeiderJeffer/Equilibrium-Analysis-in-Computational-Science","owner":"HeiderJeffer","description":"MSc. in AI ETH ZURICH and USI. ETH Zürich \u0026 USI","archived":false,"fork":false,"pushed_at":"2024-07-16T04:30:10.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T14:23:50.373Z","etag":null,"topics":["matlab","physics","simulation-modeling"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HeiderJeffer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-15T10:51:53.000Z","updated_at":"2025-01-26T06:16:46.000Z","dependencies_parsed_at":"2024-07-15T12:55:03.389Z","dependency_job_id":"6e72ec20-fe25-40df-b15b-2e8e84cb30fe","html_url":"https://github.com/HeiderJeffer/Equilibrium-Analysis-in-Computational-Science","commit_stats":null,"previous_names":["heiderjeffer/msc.-eth-zurich-and-usi-equilibrium-analysis-in-computational-science","heiderjeffer/equilibrium-analysis-in-computational-science"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HeiderJeffer/Equilibrium-Analysis-in-Computational-Science","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeiderJeffer%2FEquilibrium-Analysis-in-Computational-Science","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeiderJeffer%2FEquilibrium-Analysis-in-Computational-Science/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeiderJeffer%2FEquilibrium-Analysis-in-Computational-Science/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeiderJeffer%2FEquilibrium-Analysis-in-Computational-Science/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HeiderJeffer","download_url":"https://codeload.github.com/HeiderJeffer/Equilibrium-Analysis-in-Computational-Science/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeiderJeffer%2FEquilibrium-Analysis-in-Computational-Science/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260520952,"owners_count":23021717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matlab","physics","simulation-modeling"],"created_at":"2024-12-15T07:13:26.364Z","updated_at":"2025-06-18T08:38:12.324Z","avatar_url":"https://github.com/HeiderJeffer.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbody\u003e\n\u003cimg src = \"https://github-vistors-counter.onrender.com/github?username=https://github.com/HeiderJeffer/MSc.-ETH-Zurich-and-USI-Equilibrium-Analysis-in-Computational-Science\" alt = \"Visitors-Counter\"/\u003e\n\u003c/body\u003e\n\n#### Equilibrium Analysis in Computational Science\n#### Speaker: Heider Jeffer\n#### instructor: Mehdi Jazayeri \n#### Assistant: Dr. Sasa Nesic\n#### Topic: Computational Science - Equilibrium Analysis\n\n### Introduction to Equilibrium\nThe equilibrium of a system is a state where the system experiences no net change. Equilibrium analysis in computational science is crucial for understanding the behavior of systems under various conditions. Here, we will discuss the different types of equilibrium, their stability, and examples of how they are analyzed in various models.\n\n### Types of Equilibrium\n1. **Stable Equilibrium**: A system is in stable equilibrium if, after being slightly displaced, it returns to its original equilibrium position.\n2. **Unstable Equilibrium**: A system is in unstable equilibrium if, after being slightly displaced, it does not return to its original equilibrium position and does not remain in the displaced position.\n3. **Neutral Equilibrium**: A system is in neutral equilibrium if, after being slightly displaced, it remains in the new position without returning to the original or moving further away.\n4. **Metastable Equilibrium**: The system returns towards equilibrium as long as disturbances are not too large. The equilibrium is not globally stable; once the system crosses an unstable point, it may not return to the stable state.\n5. **Metastable Equilibrium with Multiple Stable States**: The system returns to one of several possible equilibrium states depending on the nature of the disturbance. The system is globally stable with multiple local equilibria.\n\n### Stability\nStability refers to the ability of a system to maintain its equilibrium state. For a system to be considered stable, small perturbations should not lead to significant deviations from the equilibrium.\n\n### Mechanisms and Examples\n#### Stable and Unstable Equilibria\n- **Stable Equilibrium**: If a body is displaced slightly, it returns to its equilibrium position. An example is a marble at the bottom of a bowl.\n- **Unstable Equilibrium**: If a body is displaced slightly, it moves away from its equilibrium position. An example is a marble balanced on the top of an inverted bowl.\n- **Neutral Equilibrium**: If a body is displaced slightly, it remains in the new position. An example is a marble on a flat surface.\n\n### Attractors and Their Types\nIn dynamic systems, attractors represent the states towards which a system tends to evolve. There are several types of attractors:\n1. **Stable Equilibrium (Steady State)**: The system returns to this state after small disturbances.\n2. **Limit Cycle**: The system oscillates in a closed trajectory.\n3. **Chaos**: The system exhibits complex, non-repeating patterns.\n\n#### Example: Chaotic Attractor (Lorenz Attractor)\nThe Lorenz attractor is a classic example of chaos in a system. It demonstrates how small changes in initial conditions can lead to vastly different outcomes.\n\n### Example Systems and Analysis\n#### Chemical Plant Model\nA chemical plant processes a substance through two reactors in a cascade. The reactors are modeled as reservoirs, and the variation of mass over time is proportional to the net inflow. The system is represented by state variables \\(x_1\\) and \\(x_2\\), with equations governing the mass flow:\n\n\\[\n\\begin{align*}\n\\dot{x}_1 \u0026= -ax_1 + u \\\\\n\\dot{x}_2 \u0026= -ax_2 + ax_1 \\\\\nz \u0026= ax_2 + d\n\\end{align*}\n\\]\n\nThe equilibrium point is found by setting the derivatives to zero and solving for \\(x_1\\) and \\(x_2\\). For stability, the eigenvalues of the system matrix are calculated. If all eigenvalues have negative real parts, the system is stable.\n\n### Logistic Model Example\nTo find equilibria in the logistic model, we solve the equation \\( \\frac{dN}{dt} = rN \\left(1 - \\frac{N}{K}\\right) = 0 \\). The equilibria are \\( N = 0 \\) and \\( N = K \\).\n\n- **N = 0**: Unstable equilibrium.\n- **N = K**: Stable equilibrium.\n\n### Stability of Models with Several Variables\nIn multi-variable models, stability analysis involves:\n1. Finding equilibrium points.\n2. Linearizing the model around these points.\n3. Calculating the Jacobian matrix and its eigenvalues.\n4. If all eigenvalues have negative real parts, the equilibrium is stable; otherwise, it is unstable.\n\n#### Predator-Prey Model\nIn a predator-prey model, the equilibrium densities of prey (\\(H^*\\)) and predators (\\(P^*\\)) are found by solving the system of equations. The Jacobian matrix at the equilibrium is used to determine stability.\n\n### Stability in Discrete-Time Models\nA discrete-time model is stable if the absolute value of the slope of the system's response is less than one. This condition ensures that the system's deviations from equilibrium diminish over time.\n\n### Example\n\nThese examples demonstrate how to find equilibrium points and analyze stability for different models in computational science using Python. Each example includes solving equations for equilibrium points and performing stability analysis using methods such as eigenvalues of Jacobian matrices or discrete-time stability criteria.\n\n### Example 1: Logistic Model Equilibrium Analysis\n\n```python\nimport sympy as sp\n\n# Define symbols and variables\nN = sp.symbols('N')\nr, K = sp.symbols('r K', positive=True)\n\n# Define the logistic model equation\ndN_dt = r * N * (1 - N / K)\n\n# Find equilibrium points by solving dN/dt = 0\nequilibria = sp.solve(dN_dt, N)\nprint(\"Equilibrium points for Logistic Model:\")\nfor eq in equilibria:\n    print(f\"N = {eq}\")\n\n# Stability analysis\nfor eq in equilibria:\n    jacobian_matrix = sp.Matrix([[sp.diff(dN_dt, N)]])\n    stability_condition = jacobian_matrix.subs(N, eq)\n    if stability_condition \u003c 0:\n        print(f\"N = {eq} is stable.\")\n    else:\n        print(f\"N = {eq} is unstable.\")\n```\n\n### Example 2: Chemical Plant Model Equilibrium Analysis\n\n```python\nimport numpy as np\nfrom scipy.linalg import eig\n\n# Define parameters\na = 0.5  # Example value\nu, d = 1, 1  # Example inputs\n\n# Define the system matrix and equilibrium point\nA = np.array([[-a, 0],\n              [a, -a]])\nb = np.array([[u],\n              [d]])\nx_eq = np.linalg.solve(A, b)\n\nprint(\"Equilibrium point (x1, x2):\", x_eq)\n\n# Stability analysis using eigenvalues\neigenvalues, _ = eig(A)\nprint(\"Eigenvalues:\", eigenvalues)\nif np.all(np.real(eigenvalues) \u003c 0):\n    print(\"The system is stable.\")\nelse:\n    print(\"The system is unstable.\")\n```\n\n### Example 3: Predator-Prey Model Equilibrium Analysis\n\n```python\nfrom sympy import symbols, Matrix\nfrom sympy.solvers import solve\n\n# Define symbols and variables\nH, P = symbols('H P')\na, b, c, d = 0.5, 0.5, 0.5, 0.5  # Example parameters\n\n# Define predator-prey model equations\ndH_dt = a * H - b * H * P\ndP_dt = -c * P + d * H * P\n\n# Find equilibrium points by solving dH/dt = 0 and dP/dt = 0\nequilibria = solve((dH_dt, dP_dt), (H, P))\nprint(\"Equilibrium points for Predator-Prey Model:\")\nfor eq in equilibria:\n    print(f\"H = {eq[0]}, P = {eq[1]}\")\n\n# Stability analysis\nfor eq in equilibria:\n    jacobian_matrix = Matrix([[dH_dt.diff(H), dH_dt.diff(P)],\n                              [dP_dt.diff(H), dP_dt.diff(P)]])\n    stability_condition = jacobian_matrix.subs({H: eq[0], P: eq[1]}).eigenvals()\n    if all([eig.real \u003c 0 for eig in stability_condition]):\n        print(f\"H = {eq[0]}, P = {eq[1]} is stable.\")\n    else:\n        print(f\"H = {eq[0]}, P = {eq[1]} is unstable.\")\n```\n\n\n\n### Conclusion\nUnderstanding equilibrium and stability in computational science is essential for predicting system behavior. Through various models and examples, we have seen how equilibrium analysis helps in designing and controlling systems in fields ranging from chemical processing to ecological modeling.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheiderjeffer%2Fequilibrium-analysis-in-computational-science","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheiderjeffer%2Fequilibrium-analysis-in-computational-science","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheiderjeffer%2Fequilibrium-analysis-in-computational-science/lists"}