Skip to content

Instantly share code, notes, and snippets.

View houkensjtu's full-sized avatar
🍋
Pursuing simplicity

Qian Bao houkensjtu

🍋
Pursuing simplicity
  • Shanghai
View GitHub Profile
@houkensjtu
houkensjtu / chorin_taichi.py
Created June 9, 2023 02:36
A lid-driven test case using Chorin-style projection method; implemented in Taichi.
# Implementation based on @Ceyron's Numpy version:
# https://github.com/Ceyron/machine-learning-and-simulation/blob/main/english/simulation_scripts/lid_driven_cavity_python_simple.py
# Make sure you have Taichi installed:
# pip install -U taichi
import taichi as ti
real = ti.f32
ti.init(default_fp=real, arch=ti.cpu) # you can switch to ti.gpu if you have one
N_POINTS = 41
@houkensjtu
houkensjtu / main.py
Last active February 17, 2020 15:41
A car simulator
class Component:
def __init__(self, p, s):
self.size = 0
self.power = p
self.status = s
class Engine(Component):
def __init__(self, p, s, a):
super().__init__(p, s)
@houkensjtu
houkensjtu / Val.ipynb
Created November 28, 2018 15:25
Valve
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@houkensjtu
houkensjtu / index.html
Created November 13, 2017 09:09
A backbone
<!DOCTYPE html><html lang="en">    <head>        <meta charset="utf-8">        <title>D3 Page Template</title>        <script type="text/javascript" src="d3/d3.js"></script>
        <style type="text/css">
            circle:hover {                fill: orange;            }        </style>    </head>    <body><div>    <svg width="500" height="500" style = "background-color : springgreen" id = "xaxis"></svg><svg width="500" height="500" style = "background-color : white" id = "main1"></svg></div>
<div><svg width="500" height="500" style = "background-color : white" id = "main2"></svg><svg width="500" height="500" style = "background-color : lightblue" id = "yaxis"></svg></div>
<p id="output">ccc</p>
<script>
var svg = d3.select("svg#main1"),    width = +svg.attr("width"),    height = +svg.attr("height"),    radius = 32;var svg2 = d3.select("svg#main2"),    width = +svg.attr("width"),    height = +svg.attr("height"),    radius = 32;
var svgX = d3.select("svg#xaxis"),    width = +svg.attr("width"),    height = +
@houkensjtu
houkensjtu / index.html
Created November 13, 2017 09:09
A backbone
<!DOCTYPE html><html lang="en">    <head>        <meta charset="utf-8">        <title>D3 Page Template</title>        <script type="text/javascript" src="d3/d3.js"></script>
        <style type="text/css">
            circle:hover {                fill: orange;            }        </style>    </head>    <body><div>    <svg width="500" height="500" style = "background-color : springgreen" id = "xaxis"></svg><svg width="500" height="500" style = "background-color : white" id = "main1"></svg></div>
<div><svg width="500" height="500" style = "background-color : white" id = "main2"></svg><svg width="500" height="500" style = "background-color : lightblue" id = "yaxis"></svg></div>
<p id="output">ccc</p>
<script>
var svg = d3.select("svg#main1"),    width = +svg.attr("width"),    height = +svg.attr("height"),    radius = 32;var svg2 = d3.select("svg#main2"),    width = +svg.attr("width"),    height = +svg.attr("height"),    radius = 32;
var svgX = d3.select("svg#xaxis"),    width = +svg.attr("width"),    height = +
@houkensjtu
houkensjtu / index.html
Created November 5, 2017 13:41
Line generator // source https://jsbin.com/layara
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<title>Line generator</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ['\\(','\\)'] ],
processEscapes: true