Skip to content

Instantly share code, notes, and snippets.

View argha0x's full-sized avatar
🐧
In a voyage to find Tux.

Argha Chakraborty argha0x

🐧
In a voyage to find Tux.
  • IIT-Delhi
  • New Delhi
View GitHub Profile
import numpy as np
# x1---x2---x3---...---xn
n = 4 #Number of particles
elements = n - 1
dt = 0.03
solver_iterations = 10
dt2 = dt * dt
xn = np.zeros(n)
#Setup init config of particles
it = 1
#include <iostream>
#include "glm/glm.hpp"
using namespace std;
class Result
{
public:
glm::vec3 b;
float distance;
};
#please import pandas as pd and then install these in kaggle notebook
# work with these three data
# take en.tsv
# filter 'en' sentences from train.tsv
# filter 'en' sentences from valid.tsv
#pip install langdetect
from langdetect import detect
#filter 'en' from valid.tsv
row piv 8.0
col piv 9.0
[[9. 7. 8. 5.]
[3. 3. 4. 1.]
[1. 1. 2. 0.]
[9. 7. 6. 8.]]
row piv 0.666666666666667
col piv 1.3333333333333335
#include "System.hpp"
#include "Force.hpp"
using namespace admm;
using namespace std;
using namespace Eigen;
int main(int argc, char *argv[]){
System system;
system.settings.timestep_s = 0.03;
// setup
system.settings.verbose = 0; // less prints
This file has been truncated, but you can view the full file.
TIME STEP : 1
____________________________________________
0th iteration , |X0 - X0Euler| = 0.00012499478629620175
|X1 - X1Euler| = 8.3329857531566631e-05
1th iteration , |X0 - X0Euler| = 3.6606438647883338e-05
|X1 - X1Euler| = 2.4404292432222974e-05
2th iteration , |X0 - X0Euler| = 7.5851310096091697e-06
|X1 - X1Euler| = 5.0567540057500082e-06
3th iteration , |X0 - X0Euler| = 2.9679613831748111e-05
|X1 - X1Euler| = 1.9786409220401424e-05
import numpy as np
import math
import csv
M = np.array([[2, 0], [0, 3]])
D = np.array([1, -1])[np.newaxis]
x = np.array([0, 10])
b = np.array([0, 0])
old_x = np.array([0, 0])
v = np.array([0, 0])
Y = np.array([0, 0])
3.6609081109271753e-05,2.4406054073722316e-05,0.01
0.00010982203555462113,7.3214690370804192e-05,0.02
0.00021963105223690379,0.00014642070149228914,0.03
0.00036602571729201991,0.00024401714486188553,0.04
0.00054899301479212717,0.00036599534319492477,0.05
0.00076851732758697689,0.00051234488505791376,0.060000000000000005
0.0010245804382853834,0.0006830536255240105,0.07
0.0013171615303767086,0.00087810768691909402,0.08
0.0016462371894922943,0.0010974914596637575,0.09
0.0020117814048069265,0.0013411876032094483,0.09999999999999999
At Time step 326,(Till this time step ADMM converges to Implicit Euler)
x0 = 4.51531199897907420 x1 = 6.98979200069059114
v0 = 1.65610091692460770 v1 = -1.10406727794192250
(This is the value of x, v at the start of the next time step)
Then,at Time Step 327, for the 20 admm iterations the x, z, u are printed
@argha0x
argha0x / sphere.rb
Created February 17, 2020 14:45
Generates sphere obj file(triangulated mesh) by inflating a cube
require 'pry'
require 'matrix'
def p_arr(arr)
width = arr.flatten.max.to_s.size+2
for i in (0..arr.length - 1)
for j in (0..arr.length - 1)
print arr[i][j].to_s.rjust(width + 2) + " "
end
puts ""