From 7e0b4501030aa268da323c1eaa69c8a2b29ee6a3 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Thu, 24 Apr 2025 15:22:41 -0600 Subject: Added scripts to generate tex files from markdown --- .../module_2/2_01_intro_to_numerical_methods.md | 41 -------- tutorials/module_2/2_ai_assisted_programming.md | 38 ------- tutorials/module_2/2_debugging_code.md | 88 ---------------- tutorials/module_2/2_problem_solving_strategies.md | 64 ------------ tutorials/module_2/2_version_control.md | 112 --------------------- tutorials/module_2/ai_assisted_programming.md | 38 +++++++ tutorials/module_2/debugging_code.md | 88 ++++++++++++++++ tutorials/module_2/intro_to_numerical_methods.md | 41 ++++++++ tutorials/module_2/problem_solving_strategies.md | 64 ++++++++++++ tutorials/module_2/version_control.md | 112 +++++++++++++++++++++ 10 files changed, 343 insertions(+), 343 deletions(-) delete mode 100644 tutorials/module_2/2_01_intro_to_numerical_methods.md delete mode 100644 tutorials/module_2/2_ai_assisted_programming.md delete mode 100644 tutorials/module_2/2_debugging_code.md delete mode 100644 tutorials/module_2/2_problem_solving_strategies.md delete mode 100644 tutorials/module_2/2_version_control.md create mode 100644 tutorials/module_2/ai_assisted_programming.md create mode 100644 tutorials/module_2/debugging_code.md create mode 100644 tutorials/module_2/intro_to_numerical_methods.md create mode 100644 tutorials/module_2/problem_solving_strategies.md create mode 100644 tutorials/module_2/version_control.md (limited to 'tutorials/module_2') diff --git a/tutorials/module_2/2_01_intro_to_numerical_methods.md b/tutorials/module_2/2_01_intro_to_numerical_methods.md deleted file mode 100644 index 6791aff..0000000 --- a/tutorials/module_2/2_01_intro_to_numerical_methods.md +++ /dev/null @@ -1,41 +0,0 @@ -# Numerical Methods -Engineering - -## What is a numerical method? -Numerical methods are techniques that transform mathematical problems into forms that can be solved using arithmetic and logical operations. Because digital computers excel at these computations, numerical methods are often referred to as computer mathematics. - - -## Numerical Differentiation -Forwards difference -Backwards difference - -[Read More](https://pythonnumericalmethods.studentorg.berkeley.edu/notebooks/chapter20.00-Numerical-Differentiation.html) - -## Roots and Optimization -Incremental Search -Bisection -Modified Secant -Newton-Raphson - - -## Numerical Integration - -Trapezoidal - -Simpson's Rule - -[Read More](https://pythonnumericalmethods.studentorg.berkeley.edu/notebooks/chapter21.00-Numerical-Integration.html) - - -## Numerical Solutions of Ordinary Differential Equations - -Euler's Method -- Forward -- Backwards - -Runge-Kutta Method - -[Read More](https://pythonnumericalmethods.studentorg.berkeley.edu/notebooks/chapter22.00-ODE-Initial-Value-Problems.html) - - - diff --git a/tutorials/module_2/2_ai_assisted_programming.md b/tutorials/module_2/2_ai_assisted_programming.md deleted file mode 100644 index bccedbd..0000000 --- a/tutorials/module_2/2_ai_assisted_programming.md +++ /dev/null @@ -1,38 +0,0 @@ -# AI Assisted Programming - -## What is it? -Artificial Intelligence (AI) has been around for a long time. However, not until recently did engineers make it easy and "fun" to work with. By now you probably have a pretty good idea of what AI can do. However, you may not have used an AI assistant before. As the name suggests, an AI assistant can help you develop code, speed up your writing with code suggestions and allows you to focus on solving the problem at hand rather. AI is a technology that is constantly improving. As engineers we need to *understand* how we can use AI as a tool to achieve our goals more efficiently. This section cover good practices of how we can implement AI and lists some AI assistant tools that we can use. -## Good vs. Bad uses of AI -Don't try to get AI to do work *for you* but *with you*. You need to understand what you're doing. If you don't understand what the AI is doing, then you're not in control of the work. You're not going to go far until something unexpected happens. - -AI is a great learning tool, research as show that students can benefit from using AI as personal tutor [more](https://hbsp.harvard.edu/inspiring-minds/ai-as-personal-tutor). -## Available tools -Below is a comprehensive list of tools that are available at not cost to you. - -| Name | Features | -| -------------- | -------------------------------------------------- | -| GitHub Copilot | Paid, but free for students. Integrated in GitHub. | -| ChatGPT | Free, optional paid upgrade | -| Grok | Free, optional paid upgrade | -| Gemini | Free, optional paid upgrade | -| GPT4ALL | Free and Open-Source | -| Code GPT | Free and Open-Source | -| Cody | Free and Open-Source | -| DataLab AI | Free | -| Codeium | Free | -| aiXcoder | Free | -Many of the tools above come with similar, if not, the same features. Some of the tools come as chatbots on the web and others are extensions that can be implemented in your favorite IDE. -## VSCode and GitHub Copilot Integration -We will not cover how to use VSCode in this course, however it is a very versatile IDE that comes with many other extension, for example git, github and github copilot integration. There are also other extensions for other IDE's however we will only cover some basic features that the GithHub Copilot extension in VSCode can do. - -Copilot Comes with the following features: -- Get code suggestions as you type -- Ask questions about the code -- Inline chat to generate code. -- Fix and debug code using the chat window -- Generate code documentation - -[VSCode](https://code.visualstudio.com/) -[Copilot extension](https://code.visualstudio.com/docs/copilot/setup-simplified) -## A note on integrity -If you have a non-disclosure-agreement (NDA) with your employer, it may not always be possible to use AI for security and integrity reasons as you may risk exposing confidential information with third party vendors. It is highly recommended to be able to be able to write program independently of an AI assistant. Always think before you share data. \ No newline at end of file diff --git a/tutorials/module_2/2_debugging_code.md b/tutorials/module_2/2_debugging_code.md deleted file mode 100644 index ef8dfce..0000000 --- a/tutorials/module_2/2_debugging_code.md +++ /dev/null @@ -1,88 +0,0 @@ -# Debugging Code - -### 1. Introduction - -Have you ever had a piece of code not work the way you expected? What did you do? You may have , asked a friend or used an AI assistant. In this section, the following concepts are introduced - definition of a bug, common types of bugs and debugging techniques. - -A *software bug* is an unintentional mistake or defect with a program, this comes either from when the programmer makes a mistake in writing the code or the code works in a way which has consequences that were not foreseen by the programmer. Debugging is the act removing the bugs in the software. Debugging is a normal part of programming that even experiences developers spend a lot of time on. - ---- -### 2. Types of Bugs -When writing code you are guaranteed to have bugs in your code. These bugs can be categorized in the following three groups. - -- **Syntax errors** - this type of error occurs when the code fails due to missing colons, missing indentation or a typo in code - some languages like python are case sensitive meaning that the a capital letter are different symbols. -- **Runtime errors** - e.g., dividing by zero or file not found. -- **Logical errors** - this may be the most dangerous that we need to be careful with because this error can occur without any error messages but it gives you the wrong result. - ---- -### 3. Debugging Techniques -**3.1. Print Debugging** -Insert print statements to check values of variables throughout the program. -```python -def add(x, y): - print(f"x = {x}, y = {y}") - return x + y -``` -In the example above the print statement gives us feedback on what the code is doing. The function in this example is obviously very simple, but when we start applying more complex equations or function then checking to see if the input variables are correct can indicate whether there is an issue lies within the `add()` function or if the function is given an incorrect input. - -**3.2. Rubber Duck Debugging** -This is a technique by which you explaining your code line by line in natural language to someone else, yourself or an inanimate object like a rubber duck. This can help you spot your mistake in the code. - -**3.3. Commenting Out Code** -Using comments to temporarily suppress parts of your code help you isolate and find the bug. - -**3.4. IDE Debugging tools** -Depending if you use an IDE, they often come with some sort of debugging tools such as breakpoints, step into/over and variables explorers. - -**3.5. AI Chat** -AI chat bots can help you find typo or fix logic in your code. You may find yourself going through the steps above when using an AI assistant to help you debug the code. However *never* assume that the code AI gives you works the way you intend it to work. - ---- -### 4. Interactive Debugging Activity - -In the examples debug the code and document the following: - - What the bug is - - How you found it (technique used) - - What actions you took to fix the bug -#### Code 1 -```python -def greet(name) - print("Hello, " + Name) -greet("John") -``` -#### Code 2 -```python -import numpy as np - -x = np.linspace(0,5,100) -y = 1/x - -print("Result:", y[0]) -``` -#### Code 3 -```python -def f(x): - return x**2 - 4 # Root at x = ±2 - -def bisection(a, b, tol=1e-5, max_iter=100): - if f(a) * f(b) >= 0: - print("Bisection method fails. f(a) and f(b) should have opposite signs.") - return None - - for i in range(max_iter): - c = (a + b) / 2 - if abs(f(c)) < tol: - return c - elif f(c) * f(b) < 0: # ❌ Logic error is here - a = c - else: - b = c - return (a + b) / 2 -``` - - - ---- -### 5. Reflection -- What was the most challenging bug you found? -- What debugging method did you find most useful? diff --git a/tutorials/module_2/2_problem_solving_strategies.md b/tutorials/module_2/2_problem_solving_strategies.md deleted file mode 100644 index 1a50aec..0000000 --- a/tutorials/module_2/2_problem_solving_strategies.md +++ /dev/null @@ -1,64 +0,0 @@ -# Algorithmic thinking - -## Learning Objectives - -By the end of this lesson, students will be able to: - -- Apply algorithmic thinking to solve engineering problems using computational tools. -- Translate engineering problems into structured programming logic. -- Use software tools to implement, test, and refine engineering solutions. - ---- -## 1. Define the Problem - -Like many other classes we need to frame the problem before working it. So before jumping straight into coding or building models, clearly define the engineering problem. - -- **List knowns and unknowns.** What inputs are given? What outputs are required? -- **Establish system constraints and assumptions.** Identify physical laws, design requirements, and performance limits. -- **Clarify computational objectives.** What are you trying to calculate, simulate, or optimize? - ---- -## 2. Think Algorithmically - -Since we are going to use computers to calculate our solution we first need to break the problem into logical steps that a computer can follow. - -- **Define the inputs and outputs.** What variables will the program take in, and what results will it produce? -- **Break the problem into sub-tasks.** Identify steps such as data input, logic processing and output. -- **Outline the algorithm.** Write pseudocode or flowcharts that describe the computational steps. -- **Identify patterns or formulas.** Can loops, conditionals, or equations be used to automate parts of the solution? - -**Example:** For processing stress-strain data: -1. Import data from a file. -2. Convert force and displacement to stress and strain. -3. Plot the stress-strain curve. -4. Identify the yield point or modulus. - ---- -## 3. Write & Execute the Code - -- **Choose the right tools.** Are there libraries I can use to get to my objective more effectively? -- **Write modular code.** Use functions to separate different tasks (e.g., reading data, computing values, plotting). -- **Check for syntax and logic errors.** Debug line-by-line using print statements or a debugger. - -**Example:** Write a Python script that uses NumPy and Matplotlib to load a CSV file, compute stress and strain, and generate plots. - ---- -## 4. Test and Validate - -- **Assess the feasibility of your results.** Do the values align with expected physical behavior? -- **Compare against established benchmarks.** Validate solutions using experimental data, literature values, or known theoretical limits. -- **Check units and scaling.** Ensure computations are consistent with physical meaning. - -**Example:** If your plot shows stress values in the thousands when you expect hundreds, check unit conversions in your formula. - ---- -## Case Study: Simulating a Spring-Mass System - -**Scenario:** Model the motion of a mass-spring-damper system using a numerical solver. - -1. **Define the Problem:** Set up the differential equation from Newton’s Second Law. -2. **Develop a Strategy:** Discretize time, apply numerical integration (e.g., Euler or Runge-Kutta). -3. **Execute the Code:** Write a Python function that computes motion over time. -4. **Test the Model:** Compare results with analytical solutions for undamped or lightly damped systems. -5. **Refine the Model:** Add adjustable damping and stiffness parameters. -6. **Troubleshoot Issues:** If the model becomes unstable, reduce the time step or use a more accurate integrator. \ No newline at end of file diff --git a/tutorials/module_2/2_version_control.md b/tutorials/module_2/2_version_control.md deleted file mode 100644 index 78b90db..0000000 --- a/tutorials/module_2/2_version_control.md +++ /dev/null @@ -1,112 +0,0 @@ -# Version Control Software - -## What is Version Control -Version control is a system that tracks changes to files, enabling developers to collaborate, manage code history, and revert to previous versions when needed. The most used version control software (VCS) is git. In this course git is the VCS we will be using. - -In the open-source community VCS is the -- Tracks changes and history. -- Enables collaboration among developers. -- Reduces errors by managing code versions. -- Supports branching and merging for parallel development. - -In this section is divided up into two major sections. The first section *Git* will cover the basics of how to create backups of your project. The second section will cover how to use git with GitHub to *collaborate* on projects. - ---- -## Git -Git is a version control program that tracks changes to files and directories using snapshots. It is a distributed version control system, meaning that each developer has a complete copy of the repository on their local computer. Git is the most widely used version control system and is popular among developers for its speed, flexibility, and efficiency. - -### The Three States -Pay attention now — here is the main thing to remember about Git if you want the rest of your learning process to go smoothly. Git has three main states that your files can reside in: modified, staged, and committed: - -- **Modified** means that you have changed the file but have not committed it to your database yet. -- **Staged** means that you have marked a modified file in its current version to go into your next commit snapshot. -- **Committed** means that the data is safely stored in your local database. - -This leads us to the three main sections of a Git project: the working tree, the staging area, and the Git directory. - -![Pro Git: Figure 6.](https://git-scm.com/book/en/v2/images/areas.png) -### Branching -In git, branches allow for parallel workflow on a project. It give contributors the ability to work different features at the same time. Each branch represents an independent line of development, and once a feature or fix is complete, it can be merged back into the main branch. Here is a common branching structure used in many Git projects: -- Main Branch - The main branch (a.k.a. master branch) is the default branch in a Git repository and contains the stable version of the code. -- Development Branch - is created to develop a new feature or fix a bug without affecting the main branch. It isn’t necessarily always stable, but whenever it gets to a stable state, it can be merged into master. -- Topic Branch - A topic branch is a short-lived branch that you create and use for a single particular feature or related work. -![Figure 27. A "Silo" view of progressive-stability branching](https://git-scm.com/book/en/v2/images/lr-branches-2.png) -### Best Practices -- Use descriptive commit messages. -- Commit early and often. -- Keep commits focused on a single change. -- Use feature branches for new features or bug fixes. -- Review and test changes before merging. -- Resolve conflicts promptly. -- Keep the commit history clean and organized. - -### Basic Commands -Here is a list of some git commands to get you started. -#### Starting your repository -- `git init` - Initialize a new Git repository. -- `git clone` - Clone an existing repository. -#### Committing -- `git status` - Check the status of the repository. -- `git add` - Add files to the staging area. -- `git commit` - Commit changes to the repository. -#### Branching -- `git branch` - List, create, or delete branches. -- `git checkout` - Switch between branches. -#### History/Inspection -- `git log` - View the commit history. -#### Collaborative -- `git fetch` - Fetches updates from a remote but does not merge. -- `git merge` - Merge changes from a named commit to the current branch. -- `git pull` - Fetch and merge changes from a remote repository. -- `git push` - Push changes to a remote repository. - -### More on git -Interested in learning more about git? Here's a free book that teaches you everything about git and how to use it at a professional level. Available as both HTML and PDF download: [Git Pro](https://git-scm.com/book/en/v2). - - -## GitHub - The collaborative platform -GitHub is a web-based platform that hosts Git repositories and provides collaboration tools for developers. It allows developers to share code, track issues, and collaborate on projects with other developers. GitHub is widely used for open-source projects, team collaboration, and code hosting. -### GitHub Features -- Remote Repository Hosting - GitHub allows you to host projects and code remotely on their servers. -- Issues - Issues are used to track bugs, feature -- Pull Requests - Internal request system for contributors to request code to be pulled. -### Workflow -Depending on the size of the project and whether the project is closed- or open-source, the workflow of the project will differ. In this section we cover some git workflow models and the model you're going to be using for this course. - - -**Centralized**: The project has only one central hub or *repository*, can accept code and everybody synchronizes their work with it. This model is suitable for small and closed-sourced projects. -![Centralized Workflow](https://git-scm.com/book/en/v2/images/centralized_workflow.png) - - - -**Integration-Manager:** There are multiple public variants of the code original code known as *forks*. The integration manager can decide what features to pull from the forks. This is the model that is similar to the one used on GitHub -![Integration-Manager Workfow](https://git-scm.com/book/en/v2/images/integration-manager.png) - - - -**Dictator and Lieutenants Workflow:** This is similar to the integration-manager model, however due to the size of the project. A rank of integration managers is formed. one example of this is the development of the Linux kernel. -![Dictator and Lieutenants Workflow](https://git-scm.com/book/en/v2/images/benevolent-dictator.png) - - -GitHub is designed around a particular collaboration workflow, centered on Pull Requests. This flow works whether you’re collaborating with a tightly-knit team in a single shared repository, or a globally-distributed company or network of strangers contributing to a project through dozens of forks. It is centered on the Topic Branches workflow covered in Git Branching. - - - -Here’s how it generally works: -1. Fork the project. -2. Create a topic branch from master. -3. Make some commits to improve the project. -4. Push this branch to your GitHub project. -5. Open a Pull Request on GitHub. -6. Discuss, and optionally continue committing. -7. The project owner merges or closes the Pull Request. -8. Sync the updated master back to your fork. - -### Terms -- Pull Request - A *pull request* is a request to merge changes from a feature branch into the main branch or from a forked repository to the original or "upstream" repository. -- Merge - A *merge* combines the changes from one branch into another branch. -- Conflict - A *conflict* occurs when Git cannot automatically merge changes and requires manual intervention. - - -### Code resource - Using GitHub to re-use existing code. -In your engineering career, you will most likely use a computation method that has been come up with before. In such scenarios, open-source diff --git a/tutorials/module_2/ai_assisted_programming.md b/tutorials/module_2/ai_assisted_programming.md new file mode 100644 index 0000000..bccedbd --- /dev/null +++ b/tutorials/module_2/ai_assisted_programming.md @@ -0,0 +1,38 @@ +# AI Assisted Programming + +## What is it? +Artificial Intelligence (AI) has been around for a long time. However, not until recently did engineers make it easy and "fun" to work with. By now you probably have a pretty good idea of what AI can do. However, you may not have used an AI assistant before. As the name suggests, an AI assistant can help you develop code, speed up your writing with code suggestions and allows you to focus on solving the problem at hand rather. AI is a technology that is constantly improving. As engineers we need to *understand* how we can use AI as a tool to achieve our goals more efficiently. This section cover good practices of how we can implement AI and lists some AI assistant tools that we can use. +## Good vs. Bad uses of AI +Don't try to get AI to do work *for you* but *with you*. You need to understand what you're doing. If you don't understand what the AI is doing, then you're not in control of the work. You're not going to go far until something unexpected happens. + +AI is a great learning tool, research as show that students can benefit from using AI as personal tutor [more](https://hbsp.harvard.edu/inspiring-minds/ai-as-personal-tutor). +## Available tools +Below is a comprehensive list of tools that are available at not cost to you. + +| Name | Features | +| -------------- | -------------------------------------------------- | +| GitHub Copilot | Paid, but free for students. Integrated in GitHub. | +| ChatGPT | Free, optional paid upgrade | +| Grok | Free, optional paid upgrade | +| Gemini | Free, optional paid upgrade | +| GPT4ALL | Free and Open-Source | +| Code GPT | Free and Open-Source | +| Cody | Free and Open-Source | +| DataLab AI | Free | +| Codeium | Free | +| aiXcoder | Free | +Many of the tools above come with similar, if not, the same features. Some of the tools come as chatbots on the web and others are extensions that can be implemented in your favorite IDE. +## VSCode and GitHub Copilot Integration +We will not cover how to use VSCode in this course, however it is a very versatile IDE that comes with many other extension, for example git, github and github copilot integration. There are also other extensions for other IDE's however we will only cover some basic features that the GithHub Copilot extension in VSCode can do. + +Copilot Comes with the following features: +- Get code suggestions as you type +- Ask questions about the code +- Inline chat to generate code. +- Fix and debug code using the chat window +- Generate code documentation + +[VSCode](https://code.visualstudio.com/) +[Copilot extension](https://code.visualstudio.com/docs/copilot/setup-simplified) +## A note on integrity +If you have a non-disclosure-agreement (NDA) with your employer, it may not always be possible to use AI for security and integrity reasons as you may risk exposing confidential information with third party vendors. It is highly recommended to be able to be able to write program independently of an AI assistant. Always think before you share data. \ No newline at end of file diff --git a/tutorials/module_2/debugging_code.md b/tutorials/module_2/debugging_code.md new file mode 100644 index 0000000..ef8dfce --- /dev/null +++ b/tutorials/module_2/debugging_code.md @@ -0,0 +1,88 @@ +# Debugging Code + +### 1. Introduction + +Have you ever had a piece of code not work the way you expected? What did you do? You may have , asked a friend or used an AI assistant. In this section, the following concepts are introduced - definition of a bug, common types of bugs and debugging techniques. + +A *software bug* is an unintentional mistake or defect with a program, this comes either from when the programmer makes a mistake in writing the code or the code works in a way which has consequences that were not foreseen by the programmer. Debugging is the act removing the bugs in the software. Debugging is a normal part of programming that even experiences developers spend a lot of time on. + +--- +### 2. Types of Bugs +When writing code you are guaranteed to have bugs in your code. These bugs can be categorized in the following three groups. + +- **Syntax errors** - this type of error occurs when the code fails due to missing colons, missing indentation or a typo in code - some languages like python are case sensitive meaning that the a capital letter are different symbols. +- **Runtime errors** - e.g., dividing by zero or file not found. +- **Logical errors** - this may be the most dangerous that we need to be careful with because this error can occur without any error messages but it gives you the wrong result. + +--- +### 3. Debugging Techniques +**3.1. Print Debugging** +Insert print statements to check values of variables throughout the program. +```python +def add(x, y): + print(f"x = {x}, y = {y}") + return x + y +``` +In the example above the print statement gives us feedback on what the code is doing. The function in this example is obviously very simple, but when we start applying more complex equations or function then checking to see if the input variables are correct can indicate whether there is an issue lies within the `add()` function or if the function is given an incorrect input. + +**3.2. Rubber Duck Debugging** +This is a technique by which you explaining your code line by line in natural language to someone else, yourself or an inanimate object like a rubber duck. This can help you spot your mistake in the code. + +**3.3. Commenting Out Code** +Using comments to temporarily suppress parts of your code help you isolate and find the bug. + +**3.4. IDE Debugging tools** +Depending if you use an IDE, they often come with some sort of debugging tools such as breakpoints, step into/over and variables explorers. + +**3.5. AI Chat** +AI chat bots can help you find typo or fix logic in your code. You may find yourself going through the steps above when using an AI assistant to help you debug the code. However *never* assume that the code AI gives you works the way you intend it to work. + +--- +### 4. Interactive Debugging Activity + +In the examples debug the code and document the following: + - What the bug is + - How you found it (technique used) + - What actions you took to fix the bug +#### Code 1 +```python +def greet(name) + print("Hello, " + Name) +greet("John") +``` +#### Code 2 +```python +import numpy as np + +x = np.linspace(0,5,100) +y = 1/x + +print("Result:", y[0]) +``` +#### Code 3 +```python +def f(x): + return x**2 - 4 # Root at x = ±2 + +def bisection(a, b, tol=1e-5, max_iter=100): + if f(a) * f(b) >= 0: + print("Bisection method fails. f(a) and f(b) should have opposite signs.") + return None + + for i in range(max_iter): + c = (a + b) / 2 + if abs(f(c)) < tol: + return c + elif f(c) * f(b) < 0: # ❌ Logic error is here + a = c + else: + b = c + return (a + b) / 2 +``` + + + +--- +### 5. Reflection +- What was the most challenging bug you found? +- What debugging method did you find most useful? diff --git a/tutorials/module_2/intro_to_numerical_methods.md b/tutorials/module_2/intro_to_numerical_methods.md new file mode 100644 index 0000000..6791aff --- /dev/null +++ b/tutorials/module_2/intro_to_numerical_methods.md @@ -0,0 +1,41 @@ +# Numerical Methods +Engineering + +## What is a numerical method? +Numerical methods are techniques that transform mathematical problems into forms that can be solved using arithmetic and logical operations. Because digital computers excel at these computations, numerical methods are often referred to as computer mathematics. + + +## Numerical Differentiation +Forwards difference +Backwards difference + +[Read More](https://pythonnumericalmethods.studentorg.berkeley.edu/notebooks/chapter20.00-Numerical-Differentiation.html) + +## Roots and Optimization +Incremental Search +Bisection +Modified Secant +Newton-Raphson + + +## Numerical Integration + +Trapezoidal + +Simpson's Rule + +[Read More](https://pythonnumericalmethods.studentorg.berkeley.edu/notebooks/chapter21.00-Numerical-Integration.html) + + +## Numerical Solutions of Ordinary Differential Equations + +Euler's Method +- Forward +- Backwards + +Runge-Kutta Method + +[Read More](https://pythonnumericalmethods.studentorg.berkeley.edu/notebooks/chapter22.00-ODE-Initial-Value-Problems.html) + + + diff --git a/tutorials/module_2/problem_solving_strategies.md b/tutorials/module_2/problem_solving_strategies.md new file mode 100644 index 0000000..1a50aec --- /dev/null +++ b/tutorials/module_2/problem_solving_strategies.md @@ -0,0 +1,64 @@ +# Algorithmic thinking + +## Learning Objectives + +By the end of this lesson, students will be able to: + +- Apply algorithmic thinking to solve engineering problems using computational tools. +- Translate engineering problems into structured programming logic. +- Use software tools to implement, test, and refine engineering solutions. + +--- +## 1. Define the Problem + +Like many other classes we need to frame the problem before working it. So before jumping straight into coding or building models, clearly define the engineering problem. + +- **List knowns and unknowns.** What inputs are given? What outputs are required? +- **Establish system constraints and assumptions.** Identify physical laws, design requirements, and performance limits. +- **Clarify computational objectives.** What are you trying to calculate, simulate, or optimize? + +--- +## 2. Think Algorithmically + +Since we are going to use computers to calculate our solution we first need to break the problem into logical steps that a computer can follow. + +- **Define the inputs and outputs.** What variables will the program take in, and what results will it produce? +- **Break the problem into sub-tasks.** Identify steps such as data input, logic processing and output. +- **Outline the algorithm.** Write pseudocode or flowcharts that describe the computational steps. +- **Identify patterns or formulas.** Can loops, conditionals, or equations be used to automate parts of the solution? + +**Example:** For processing stress-strain data: +1. Import data from a file. +2. Convert force and displacement to stress and strain. +3. Plot the stress-strain curve. +4. Identify the yield point or modulus. + +--- +## 3. Write & Execute the Code + +- **Choose the right tools.** Are there libraries I can use to get to my objective more effectively? +- **Write modular code.** Use functions to separate different tasks (e.g., reading data, computing values, plotting). +- **Check for syntax and logic errors.** Debug line-by-line using print statements or a debugger. + +**Example:** Write a Python script that uses NumPy and Matplotlib to load a CSV file, compute stress and strain, and generate plots. + +--- +## 4. Test and Validate + +- **Assess the feasibility of your results.** Do the values align with expected physical behavior? +- **Compare against established benchmarks.** Validate solutions using experimental data, literature values, or known theoretical limits. +- **Check units and scaling.** Ensure computations are consistent with physical meaning. + +**Example:** If your plot shows stress values in the thousands when you expect hundreds, check unit conversions in your formula. + +--- +## Case Study: Simulating a Spring-Mass System + +**Scenario:** Model the motion of a mass-spring-damper system using a numerical solver. + +1. **Define the Problem:** Set up the differential equation from Newton’s Second Law. +2. **Develop a Strategy:** Discretize time, apply numerical integration (e.g., Euler or Runge-Kutta). +3. **Execute the Code:** Write a Python function that computes motion over time. +4. **Test the Model:** Compare results with analytical solutions for undamped or lightly damped systems. +5. **Refine the Model:** Add adjustable damping and stiffness parameters. +6. **Troubleshoot Issues:** If the model becomes unstable, reduce the time step or use a more accurate integrator. \ No newline at end of file diff --git a/tutorials/module_2/version_control.md b/tutorials/module_2/version_control.md new file mode 100644 index 0000000..78b90db --- /dev/null +++ b/tutorials/module_2/version_control.md @@ -0,0 +1,112 @@ +# Version Control Software + +## What is Version Control +Version control is a system that tracks changes to files, enabling developers to collaborate, manage code history, and revert to previous versions when needed. The most used version control software (VCS) is git. In this course git is the VCS we will be using. + +In the open-source community VCS is the +- Tracks changes and history. +- Enables collaboration among developers. +- Reduces errors by managing code versions. +- Supports branching and merging for parallel development. + +In this section is divided up into two major sections. The first section *Git* will cover the basics of how to create backups of your project. The second section will cover how to use git with GitHub to *collaborate* on projects. + +--- +## Git +Git is a version control program that tracks changes to files and directories using snapshots. It is a distributed version control system, meaning that each developer has a complete copy of the repository on their local computer. Git is the most widely used version control system and is popular among developers for its speed, flexibility, and efficiency. + +### The Three States +Pay attention now — here is the main thing to remember about Git if you want the rest of your learning process to go smoothly. Git has three main states that your files can reside in: modified, staged, and committed: + +- **Modified** means that you have changed the file but have not committed it to your database yet. +- **Staged** means that you have marked a modified file in its current version to go into your next commit snapshot. +- **Committed** means that the data is safely stored in your local database. + +This leads us to the three main sections of a Git project: the working tree, the staging area, and the Git directory. + +![Pro Git: Figure 6.](https://git-scm.com/book/en/v2/images/areas.png) +### Branching +In git, branches allow for parallel workflow on a project. It give contributors the ability to work different features at the same time. Each branch represents an independent line of development, and once a feature or fix is complete, it can be merged back into the main branch. Here is a common branching structure used in many Git projects: +- Main Branch - The main branch (a.k.a. master branch) is the default branch in a Git repository and contains the stable version of the code. +- Development Branch - is created to develop a new feature or fix a bug without affecting the main branch. It isn’t necessarily always stable, but whenever it gets to a stable state, it can be merged into master. +- Topic Branch - A topic branch is a short-lived branch that you create and use for a single particular feature or related work. +![Figure 27. A "Silo" view of progressive-stability branching](https://git-scm.com/book/en/v2/images/lr-branches-2.png) +### Best Practices +- Use descriptive commit messages. +- Commit early and often. +- Keep commits focused on a single change. +- Use feature branches for new features or bug fixes. +- Review and test changes before merging. +- Resolve conflicts promptly. +- Keep the commit history clean and organized. + +### Basic Commands +Here is a list of some git commands to get you started. +#### Starting your repository +- `git init` - Initialize a new Git repository. +- `git clone` - Clone an existing repository. +#### Committing +- `git status` - Check the status of the repository. +- `git add` - Add files to the staging area. +- `git commit` - Commit changes to the repository. +#### Branching +- `git branch` - List, create, or delete branches. +- `git checkout` - Switch between branches. +#### History/Inspection +- `git log` - View the commit history. +#### Collaborative +- `git fetch` - Fetches updates from a remote but does not merge. +- `git merge` - Merge changes from a named commit to the current branch. +- `git pull` - Fetch and merge changes from a remote repository. +- `git push` - Push changes to a remote repository. + +### More on git +Interested in learning more about git? Here's a free book that teaches you everything about git and how to use it at a professional level. Available as both HTML and PDF download: [Git Pro](https://git-scm.com/book/en/v2). + + +## GitHub - The collaborative platform +GitHub is a web-based platform that hosts Git repositories and provides collaboration tools for developers. It allows developers to share code, track issues, and collaborate on projects with other developers. GitHub is widely used for open-source projects, team collaboration, and code hosting. +### GitHub Features +- Remote Repository Hosting - GitHub allows you to host projects and code remotely on their servers. +- Issues - Issues are used to track bugs, feature +- Pull Requests - Internal request system for contributors to request code to be pulled. +### Workflow +Depending on the size of the project and whether the project is closed- or open-source, the workflow of the project will differ. In this section we cover some git workflow models and the model you're going to be using for this course. + + +**Centralized**: The project has only one central hub or *repository*, can accept code and everybody synchronizes their work with it. This model is suitable for small and closed-sourced projects. +![Centralized Workflow](https://git-scm.com/book/en/v2/images/centralized_workflow.png) + + + +**Integration-Manager:** There are multiple public variants of the code original code known as *forks*. The integration manager can decide what features to pull from the forks. This is the model that is similar to the one used on GitHub +![Integration-Manager Workfow](https://git-scm.com/book/en/v2/images/integration-manager.png) + + + +**Dictator and Lieutenants Workflow:** This is similar to the integration-manager model, however due to the size of the project. A rank of integration managers is formed. one example of this is the development of the Linux kernel. +![Dictator and Lieutenants Workflow](https://git-scm.com/book/en/v2/images/benevolent-dictator.png) + + +GitHub is designed around a particular collaboration workflow, centered on Pull Requests. This flow works whether you’re collaborating with a tightly-knit team in a single shared repository, or a globally-distributed company or network of strangers contributing to a project through dozens of forks. It is centered on the Topic Branches workflow covered in Git Branching. + + + +Here’s how it generally works: +1. Fork the project. +2. Create a topic branch from master. +3. Make some commits to improve the project. +4. Push this branch to your GitHub project. +5. Open a Pull Request on GitHub. +6. Discuss, and optionally continue committing. +7. The project owner merges or closes the Pull Request. +8. Sync the updated master back to your fork. + +### Terms +- Pull Request - A *pull request* is a request to merge changes from a feature branch into the main branch or from a forked repository to the original or "upstream" repository. +- Merge - A *merge* combines the changes from one branch into another branch. +- Conflict - A *conflict* occurs when Git cannot automatically merge changes and requires manual intervention. + + +### Code resource - Using GitHub to re-use existing code. +In your engineering career, you will most likely use a computation method that has been come up with before. In such scenarios, open-source -- cgit v1.2.3