Skip to content

Math & Physics Simulation – A C++ project for mathematical and physics simulations, including vector fields, differentiation, and integration using Euler’s method. πŸš€

Notifications You must be signed in to change notification settings

stdmedoth/spinoza

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Spinoza - Math & Physics Simulation Library

Spinoza is a C++ library designed for high-performance mathematical and physics simulations. It provides a set of tools for vector operations, numerical differentiation, and integration. The library is built using pure C++ and does not rely on any external dependencies beyond the C++ Standard Library.

πŸ”₯ Features

  • βœ… N-dimensional vector operations
  • βœ… Scalar and vector field simulation
  • βœ… Numerical differentiation using Euler's method
  • βœ… Numerical integration using Euler's method
  • βœ… Expandable framework for custom simulations

πŸš€ Getting Started

Prerequisites

  • C++17 or later compiler
  • CMake for building

Install CMake

  • Ubuntu/Debian:

    sudo apt-get install cmake
  • macOS (Homebrew):

    brew install cmake

Installation

  1. Clone the repository:

    git clone https://github.com/stdmedoth/spinoza.git
    cd spinoza
  2. Create a build directory and navigate into it:

    mkdir build && cd build
  3. Generate build files with CMake:

    cmake ..
  4. Build the project:

    make
  5. The compiled library will be available for linking in your project.

Integrating Spinoza in Your Project

If you're using CMake, simply link the Spinoza library:

add_subdirectory(spinoza)
target_link_libraries(my_project PRIVATE spinoza)

If you're manually compiling:

g++ -std=c++17 -I./include my_program.cpp -o my_program

πŸ§‘β€πŸ’» Usage Example

Here's a better example of how to use Spinoza for field simulations:

#include <iostream>
#include "Field.hpp"
#include "VectorField.hpp"
#include "ScalarField.hpp"
#include "Space.hpp"

int main()
{
    // Define a 3D vector space with 10,000 elements
    Space<double, 3, 10000> domain;
    Field<double, 10000> image;
    Space<double, 3, 10000> vector_image;

    // Initialize the scalar field and vector field values
    for (int i = 0; i < 10000; i++)
    {
        double x = 0.001 * i;
        double y = 0.002 * i;
        double z = 0.003 * i;
        domain[i] = Vector<double, 3>({x, y, z});
        image[i] = x + y + z;
        vector_image[i] = Vector<double, 3>({x, y, z});
    }

    // Create a scalar field (temperature) and output its image
    ScalarField<double, 3, 10000> temperature(domain, image);
    image = temperature.getImage();
    for (int i = 0; i < 10000; i++)
    {
        std::cout << image[i] << "\n";
    }

    // Create a vector field (position) and output its image
    VectorField<double, 3, 10000> position(domain, vector_image);
    vector_image = position.getImage();
    for (int i = 0; i < 10000; i++)
    {
        std::cout << vector_image[i] << "\n";
    }

    return 0;
}

Explanation:

  • Space: Represents a space with vectors.
  • Field: Represents the image of a scalar or vector field.
  • ScalarField: Represents a scalar field where the value at each point is a scalar (used for temperature or other scalar quantities).
  • VectorField: Represents a vector field where the value at each point is a vector (used for position or other vector quantities).
  • getImage(): Retrieves the field values as an array.

In the example:

  • A scalar field temperature is computed and printed.
  • A vector field position is computed and printed.

πŸ“‚ Project Structure

/spinoza
β”‚
β”œβ”€β”€ /include                # Header files
β”œβ”€β”€ /src                    # Source files
β”œβ”€β”€ /examples               # Example programs
β”œβ”€β”€ CMakeLists.txt          # CMake configuration
β”œβ”€β”€ README.md               # Documentation
β”œβ”€β”€ LICENSE                 # License information

🀝 Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch: git checkout -b my-feature
  3. Commit your changes: git commit -am 'Added new feature'
  4. Push to your branch: git push origin my-feature
  5. Submit a pull request.

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ’‘ Explore the world of math & physics with Spinoza! πŸš€


About

Math & Physics Simulation – A C++ project for mathematical and physics simulations, including vector fields, differentiation, and integration using Euler’s method. πŸš€

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published