{"id":30505606,"url":"https://github.com/gpuengineering/pdesolvers","last_synced_at":"2025-09-22T03:06:20.924Z","repository":{"id":259764101,"uuid":"867178506","full_name":"GPUEngineering/PDESolvers","owner":"GPUEngineering","description":"GPU-accelerated solution of PDEs","archived":false,"fork":false,"pushed_at":"2025-08-17T03:21:43.000Z","size":33228,"stargazers_count":2,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-17T03:22:32.932Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GPUEngineering.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2024-10-03T15:29:36.000Z","updated_at":"2025-05-06T20:04:59.000Z","dependencies_parsed_at":"2024-10-27T22:38:45.631Z","dependency_job_id":"21011167-0074-4363-9d0f-1f5bab6e4e99","html_url":"https://github.com/GPUEngineering/PDESolvers","commit_stats":null,"previous_names":["gpuengineering/pdesolvers"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GPUEngineering/PDESolvers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GPUEngineering%2FPDESolvers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GPUEngineering%2FPDESolvers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GPUEngineering%2FPDESolvers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GPUEngineering%2FPDESolvers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GPUEngineering","download_url":"https://codeload.github.com/GPUEngineering/PDESolvers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GPUEngineering%2FPDESolvers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272099344,"owners_count":24873429,"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","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-08-25T16:38:37.327Z","updated_at":"2025-09-22T03:06:15.873Z","avatar_url":"https://github.com/GPUEngineering.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PDESolvers ૮₍  ˶•⤙•˶ ₎ა\n\nA Python package for solving partial differential equations (PDEs), including the one-dimensional heat equation and the Black-Scholes equation, using numerical methods such as explicit and Crank-Nicolson finite difference schemes. Features include built-in plotting, benchmarking and support for financial applications such as option pricing.\n\n## 📦 Installation\nThe pdesolvers package can be installed using pip. To install the package, run the following command:\n```\npip install pdesolvers\n```\nUpdating the package to its latest version can be done with:\n```\npip install --upgrade pdesolvers\n```\n\n## 🧩 Supported Features\n### Solvers\n- ✅ **Explicit method**\n- ✅ **Crank-Nicolson method**\n\n### Equations\n- ✅ **1D Heat Equation**\n- ✅ **Black-Scholes Equation for vanilla European options**\n\n### Pricing Methods\n- ✅ **Monte Carlo Pricing**\n- ✅ **Analytical Black-Scholes formula**\n\n## 📁 Project Structure\n```plaintext\nPDESolvers/\n├── pdesolvers/                # Main Python package\n│   ├── enums/                 # Enum definitions (e.g., option types, greeks)\n│   ├── optionspricing/        # Modules for Monte Carlo and Black-Scholes pricing\n│   ├── pdes/                  # PDE definitions (HeatEquation, BlackScholesEquation, etc.)\n│   ├── solution/              # Solution classes (Solution1D, SolutionBlackScholes, etc.)\n│   ├── solvers/               # Explicit, Crank-Nicolson, etc.\n│   ├── tests/                 # Unit tests for Python components\n│   ├── utils/                 # Helper functions\n│   ├── __init__.py            # Makes it a package\n├── GPUSolver/                 # GPU-accelerated module\n│   ├── cpu/                   # CPU-side implementations (C++)\n│   ├── gpu/                   # CUDA kernels and GPU logic\n│   ├── tests/                 # Tests for GPU and C++ logic\n```\n\u003e 📝 **Note:** The Python and C++/CUDA libraries are currently developed as separate components and are not integrated. The Python library can be used independently via PyPI, while the GPU-accelerated solvers are available as a standalone C++/CUDA project.\n\n## 📊 Export Options\nUse **_export=True_** flags in plotting functions or benchmarking methods to export:\n- **PDF**: Save plots as PDF files.\n- **CSV**: Save benchmark results as CSV files.\n\n## 🚀 Usage\nTo use the package, you can import the desired modules and classes and create an instance of the solvers.\n\n### Example usage of the 1D heat equation solver\n```python\nfrom pdesolvers import HeatEquation, Heat1DExplicitSolver, Heat1DCNSolver\nimport numpy as np\n\nequation = (HeatEquation(1, 100,30,10000, 0.01)\n            .set_initial_temp(lambda x: np.sin(np.pi * x) + 5)\n            .set_left_boundary_temp(lambda t: 20 * np.sin(np.pi * t) + 5)\n            .set_right_boundary_temp(lambda t: t + 5))\n\nsolution1 = Heat1DCNSolver(equation).solve()\nsolution2 = Heat1DExplicitSolver(equation).solve()\n\nresult = solution1.get_result()\nsolution1.plot()\n```\n\n### Example usage of the Black-Scholes equation solver\n```python\nfrom pdesolvers import BlackScholesEquation, BlackScholesExplicitSolver, BlackScholesCNSolver, OptionType, Greeks\n\nequation = BlackScholesEquation(OptionType.EUROPEAN_CALL, 300, 295, 0.05, 0.2, 1, 100, 10000)\n\nsolution1 = BlackScholesExplicitSolver(equation).solve()\nsolution2 = BlackScholesCNSolver(equation).solve()\n\nsolution1.plot()\nsolution1.plot_greek(Greeks.GAMMA)\nsolution2.get_execution_time()\n```\n\n### Example usage of Monte Carlo Pricing\n```python\nfrom pdesolvers import MonteCarloPricing, OptionType\n\npricing = MonteCarloPricing(OptionType.EUROPEAN_CALL, 300, 290, 0.05, 0.2, 1, 365, 1000, 78)\noption_price = pricing.get_monte_carlo_option_price()\n\npricing.plot_price_paths()\npricing.plot_distribution_of_payoff()\npricing.plot_distribution_of_final_prices()\n```\n\n### Example usage of Analytical Black-Scholes formula\n```python\nfrom pdesolvers import BlackScholesFormula, OptionType\n\npricing = BlackScholesFormula(OptionType.EUROPEAN_CALL, 300, 290, 0.05, 0.2, 1)\noption_price = pricing.get_black_scholes_merton_price()\n```\n\n### Using Real Historical Data\n```python\nfrom pdesolvers import HistoricalStockData, MonteCarloPricing, OptionType\n\nticker = 'NVDA'\n\nhistorical_data = HistoricalStockData(ticker)\nhistorical_data.fetch_stock_data( \"2024-02-28\",\"2025-02-28\")\n\nsigma, mu = historical_data.estimate_metrics()\ninitial_price = historical_data.get_initial_stock_price()\nclosing_prices = historical_data.get_closing_prices()\n\npricing = MonteCarloPricing(OptionType.EUROPEAN_CALL, initial_price, 160, mu, sigma, 1, len(closing_prices), 1000, 78)\n\npricing.plot_price_paths(export=True)\n```\n\u003e 📝 **Note:** You don't necessarily need to use the HistoricalStockData class — you're free to use raw yfinance data directly.\nUse the built-in tools only if you want to estimate metrics like volatility or mean return.\n\n### 📊 Comparing Interpolated Grid Solutions\n```python\nfrom pdesolvers import BlackScholesEquation, BlackScholesExplicitSolver, BlackScholesCNSolver, OptionType\n\nequation1 = BlackScholesEquation(OptionType.EUROPEAN_CALL, S_max=300, K=100, r=0.05, sigma=0.2, expiry=1, s_nodes=100, t_nodes=1000)\nequation2 = BlackScholesEquation(OptionType.EUROPEAN_CALL, S_max=300, K=100, r=0.05, sigma=0.2, expiry=1)\n\nsolution1 = BlackScholesExplicitSolver(equation1).solve()\nsolution2 = BlackScholesCNSolver(equation1).solve()\n\nerror = solution1 - solution2\n```\n\n### 📊 Additional Benchmarks\n```python\nfrom pdesolvers import MonteCarloPricing, BlackScholesFormula, OptionType\n\nnum_simulations_list = [ 20, 50, 100, 250, 500, 1000, 2500 ]\n\npricing_1 = BlackScholesFormula(OptionType.EUROPEAN_CALL, 300, 290, 0.05, 0.2, 1)\npricing_2 = MonteCarloPricing(OptionType.EUROPEAN_CALL, 300, 290, 0.05, 0.2, 1, 365, 1000000, 78)\n\nbs_price = pricing_1.get_black_scholes_merton_price()\nmonte_carlo_price = pricing_2.get_monte_carlo_option_price()\n\npricing_2.get_benchmark_errors(bs_price, num_simulations_list=num_simulations_list)\npricing_2.plot_convergence_analysis(bs_price, num_simulations_list=num_simulations_list, export=True)\n```\n\u003e 📝 **Note:** The export flag used in the example above will save the plot as a PDF file in the current working directory.\n\n## 🧠 Limitations\n- The package currently supports only one-dimensional PDEs.\n- Currently limited to vanilla European options.\n\n## 🔒 License\nThis project is licensed under the Apache License 2.0. See the [LICENSE](./LICENSE.md) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpuengineering%2Fpdesolvers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgpuengineering%2Fpdesolvers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpuengineering%2Fpdesolvers/lists"}