Skip to content

Instantly share code, notes, and snippets.

View SanPen's full-sized avatar
📐
Working on GridCal!

Santiago Peñate Vera SanPen

📐
Working on GridCal!
View GitHub Profile
@kshitizkhanal7
kshitizkhanal7 / ps_optimization_cpuvsgpu.py
Created December 29, 2024 17:27
Benchmarking power system optimization: CPU (using PyPSA) and GPU (using custom solution)
#pip install pypsa cupy-cuda12x clarabel cvxpy
import numpy as np
import cupy as cp
import cvxpy as cvx
import pandas as pd
import time
import pypsa
import matplotlib.pyplot as plt
from tqdm.notebook import tqdm
@joezuntz
joezuntz / mpi4py_trivial.py
Created February 5, 2015 15:41
Simplest possible mpi4py job splitting
#Suppose you have a collection of tasks, which in this example I'll assume is just running a function f.
#If these tasks are completely separate and independent the most then you can parallelize them easily.
#In this gist I'll show the simplest possible way to do this using mpi4py.
#There are better ways to do this, in particular if the tasks vary significantly in time taken to run.
import mpi4py.MPI
def f(i):
"A fake task - in this case let just open a file and write a number to it"
#open file with name based on task number