# TUG Documentation TUG is a Julia package that provides a framework for solving transport problems, notably diffusion, on uniform grids. It implements different numerical approaches, including implicit BTCS (Backward Time, Central Space) Euler and parallel 2D ADI (Alternating Direction Implicit). ```@contents ``` ## Introduction TUG, originally developed as a C++ library, is now available as a Julia package. It aims to offer a comprehensive toolkit for solving transport problems, such as diffusion and advection, on uniform grids. ## Installation If TUG is locally cloned on your machine, you can install it by pointing to the local path. Open Julia REPL and follow these steps: ```julia using Pkg Pkg.develop(path="path/to/tug/julia/TUG") # Replace with the actual path to the TUG directory using TUG ``` ## Getting Started Below are some basic examples of using TUG. For more detailed information, see the API section. For more advanced examples, see the test files in the `test` directory. ### Creating a Simulation To create a simulation with TUG, you first need to set up a grid and boundary conditions. Here is an example of setting up a basic simulation: ```julia using TUG # Create a 1D grid grid = TUG.Grid{Float64}(5, ones(1, 5)) # Define boundary conditions boundary = TUG.Boundary{Float64}(grid) # Initialize a simulation with default parameters simulation = TUG.Simulation{Float64}(grid, boundary) ``` ### Running a Simulation After setting up the simulation, you can run it and analyze the results: ```julia # Set initial concentrations TUG.setConcentrations!(grid, [1.0, 1.0, 20.0, 1.0, 1.0]) # Run the simulation TUG.run(simulation) # Retrieve the concentrations after simulation concentrations = TUG.getConcentrations(grid) ``` ### Advanced Setup You can also customize your simulation with different parameters: ```julia # Create a simulation with custom parameters simulation = TUG.Simulation{Float64}( grid, boundary; approach = TUG.FTCS, iterations = 2, timestep = 0.2, consoleOutput = TUG.CONSOLE_OUTPUT_ON, csvOutput = TUG.CSV_OUTPUT_ON ) ``` ### Dynamic Simulation For dynamic simulations where the concentration is manipulated externally during runtime: ```julia # Initialize a dynamic simulation dynamicSimulation = TUG.DynamicSimulation{Float64}(grid, boundary; timestep = 0.1) # Create and update the grid over iterations TUG.createGrid(dynamicSimulation) for _ = 1:20 TUG.next(dynamicSimulation) # Update the concentration end ``` ## API Reference For a detailed reference of all functionalities, see the API section: ```@autodocs Modules = [TUG] ```