Skip to content

Instantly share code, notes, and snippets.

View dutta-alankar's full-sized avatar
🙂

Alankar Dutta dutta-alankar

🙂
View GitHub Profile
@dutta-alankar
dutta-alankar / init.c
Last active April 10, 2024 09:22
Boundary condition in `PLUTO`
// Following must be put in `definitions.h` for this to work
/* #define INTERNAL_BOUNDARY YES */
if (side == 0) { // -- select active cells --
RBox dom_box;
int convert_to_cons = 0;
DOM_LOOP(k,j,i) {
int num_cells = 1;
// IDIR --> x-dirction
if ( (grid->xgc[IDIR][i] >= (grid->xl_glob[IDIR][grid->gend[IDIR]-num_cells+1]))
&& (grid->xgc[IDIR][i] <= (grid->xr_glob[IDIR][grid->gend[IDIR]])) ){
@dutta-alankar
dutta-alankar / dijkstra.py
Last active April 10, 2024 15:46
Demonstration of Dijkstra's algorithm
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 10 01:05:05 2024
@author: alankar
"""
from typing import List, Optional, Union
_large_distance = 10000
@dutta-alankar
dutta-alankar / spherical_harmonics.c
Created April 29, 2024 14:45
Spherical harmonics Y_lm in C
#include <stdio.h>
#include <gsl/gsl_sf_legendre.h>
#include <gsl/gsl_sf_result.h>
int main() {
double theta = 1.2; // Example value for theta
double phi = 0.8; // Example value for phi
int l = 2; // Spherical harmonic degree
int m = 1; // Spherical harmonic order
@dutta-alankar
dutta-alankar / SphericalBoxCC.md
Last active April 30, 2024 11:34
Cloud crushing in a spherical box

Chevalier & Clegg 1985 (CC85) wind is spherically symmetric. So a coordinate system in the simulation that naturally aligns with the wind geometry allows the steady wind profiles to remain numerically stable for an arbitrarily long time. Therefore, it is worth setting cloud crushing problem in spherical coordinates to study it cloud-wind interaction in an adiabatically expanding wind, like CC85.

To retain the hierarchy that wind corresponds to hot gas and mixed gas has an intermediate temperature between cold cloud and the wind. The physically relevant portion of the domain where the general cloud crushing results are applicable is where $T_{\rm wind} \ge T_{\rm mix}$, where $T_{\rm mix} = T_{\rm wind}/\sqrt{\chi}$, and $\chi$ is the initial temperature contrast between the wind and the cloud.

Here is the entire simulation domain where the code length is the initial cloud radius. For this visualization, I have chosen $t_{\rm cool, mix}/t_{\rm cc}=0.1$. This corresponds to one of the largest clouds in the

@dutta-alankar
dutta-alankar / dask-requirements.txt
Created June 5, 2024 05:59
Modules required for a complete `Dask` setup using `python 3.11.4`
anyio==4.4.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==2.4.1
async-lru==2.0.4
attrs==23.2.0
Babel==2.15.0
beautifulsoup4==4.12.3
bleach==6.1.0
@dutta-alankar
dutta-alankar / dask-on-slurm.py
Last active June 17, 2024 05:13
Dask on Chandra slurm cluster
from dask_jobqueue import SLURMCluster
from dask.distributed import Client
import dask
import dask.array as da
import subprocess
import time
# Configure the SLURM cluster
cluster = SLURMCluster(
queue='debug', # Replace with your Slurm queue name
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 16 21:57:11 2024
@author: alankar
Usage: time mpiexec -n <num_procs> python guess_pdfPass-parallel.py
Dependency: qpdf (https://github.com/qpdf/qpdf), tested with version 11.9.1
Note: Make sure qpdf and its libraries are added to PATH and LD_LIBRARY_PATH respectively
Thanks: Samriddhi Sankar Maity