I'm messing around with the swarzchild metric, and I keep getting errors. First, it was a memory, which I could have guessed, 10000x10000 array, so I lowered it to 1000x1000 and it moves past that point, now.
However, this is where I'm getting my error:
Gravity = zeros([1000,1000])
while i <...
Hi! I have this code which should simulate a sod shock tube like this: https://en.wikipedia.org/wiki/Sod_shock_tube But when i plot density versus distance I just get something like a noisy signal. Any idea where I am doing something wrong?
from matplotlib import pyplot as plt
import numpy as...
Hi people,
I've "enrolled" into the edx MITx 6.00.2x course on python and data science, but I don't plan to get a certificate and I started so late that all the problems I'm facing aren't due anymore so I think this gives me the right to seek help here.
Basically the task is to simulate some...
I've installed Python 3.5.1 successfully, and I've downloaded add-on modules such as numpy, scipy, matplotlib, etc, but when I try to import them into python I get the following: "ImportError: No module named 'numpy'", etc.
There's no executable file in the numpy download to activate anything...
Hi! I have to fit a blackbody spectrum to some data points. The y-axis is in mJy and the x-axis is in log_10(freq). My code looks like this:
from __future__ import division
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import curve_fit
h = 6.63*10**(-34)
c =...
Homework Statement
Somewhat irrelevant, but we need to simulate the redshift for a star system. Pretty open ended. Single star, binary, whatever.
The problem is this:
TypeError: <lambda>() takes at most 1 argument (5 given)
And upon searching, most people who get this error have a function that...
I'd appreciate it if someone can give me a little guidance here. I'm slated to be entering a Ph.D. program in the fall where I'll be working on a machine intelligence project under a DARPA grant designed to create autonomous rovers. They want me because of my background in understanding the...
Homework Statement
Enter a minimum height and velocity into plot function and return a velocity-height plot.
Homework EquationsThe Attempt at a Solution
# Find length of general list
n = len(K)
# Build a list for time [0,20] seconds ( Global)
time = n*[0.0]
# Acceleration of gravity
g =...
Hi all,
I have recently created an nbody simulation in Vpython for a few thousand particles where each particle is about 4000 times the mass of our Sun. Vpython is doing exactly what I want it to do the only problem being the output is extremely low quality (black spheres on a white...
I'm trying to write a simple script in blender python in order to show load deflection in cloth simulation. My question is: Is it possible to translate the change of length (distance between two nodes), into a force? (Newton between those nodes)?
In addition you will find a minimal example. The...
I am using the monte carlo method to calculate the integral of cos^2(x). This is done using N random numbers. In my case I am doing it for 10^i random numbers when i ranges from 1-6. I want to calculate the error on the integral for each value of i used.
I know for each value of N I want to...
Dear Forum,
I am trying to use Python to control FLIR camera (tau 2.4) but I do not know there is possible or not?
I say that because I see when I connect IR camera to the computer using USB, it shows COM port in the Device Manager and I've seen python possible to work with COM port through...
Homework Statement
I'm using python to calculate the age of the universe, by working out the distmodulus for a set of galaxys (using the V and I bands) then working out the distance in parsecs and then hubbles constant etc... I keep getting values that are 10s of magnitudes out which I assume...
Homework Statement
A rocket can either fire or not fire for a duration of 1-100ms with equal probability of firing/not firing. Determine how far it will go in the first 2 seconds of flight.
Homework EquationsThe Attempt at a Solution
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a...
I am reading Mark Newman's Computational Physics textbook. He goes over calculating integrals with Simpsons's Rule and the Trapezoidal Rule, and then he goes over calculating their errors. Why would I have to ever worry about the error of the integral?
He has the chapters online at his website...
Hello all,
If this has been asked before, please forgive me; what can Python be used for? Is it good for programming apps and whatnot? I have never done any programming before, so this is my very first programming language that I have just started learning.
Thanks for answering
Hello,
My name is Thibaut. I am looking to improve my code in python in order to have a better look a my Fourier transform. as you can see on the image, we barely see any detail of the peaks on the image. Also it's not centred. the zero order peak in on the corner, not in the centre.
Any idea...
I had a brief stint with Python a year or two ago, and after I learned of the Raspberry Pi I knew I should try to learn again. I purchased this book, knowing full well that the online resources would be sufficient, and some of the code doesn't seem to work.
hello_str = "Hello World"...
I'm trying to write a program to calculate the trajectory of a projectile with air resistance. I've made the following function which calculates the position of the particle based on a given launch angle and initial velocity:
def traj_fr(angle, v0): #function that computes...
Hello,
So I'm in high school and I wanted to self-study programming. In summer I completed the course Introduction to Computer Science and Programming Using Python on edX . I really liked it. I was wondering what I should do next and from where? Should I learn a different language (C , C++ and...
Hi,
I've been trying to write a simple binary file in Python 3 and have not yet been able to find a clear answer / solution online.
Could you please suggest a simple way to read / write binary files in Python 3?
My Code:
# Create Binary File
def dec_base(k,b=2):
""" Default base is 2...
Hey guys,
I'm going to be honest and say I'm so stuck on this assignment - I really need help!
I've took on a third year computational physics course last year - turn your weaknesses into strengths someone told me.
Well, I failed and I'm back doing it again this year!
So, I just have to pass...
Hi everyone:
I wanted to design a 2-dimensional gravity simulator as part of a larger research project. I wrote it in Python using numpy to store positions, velocities, and accelerations, and matplotlib to display the trajectories; code is available upon request.
In order to solve the problem...
I am no programmer but I want to learn for personal development.
so physicsy type guys recommended Python. I downloaded it and have been playing.
my goals for programming are three;
1. learn to code just for fun
2. do calculations and numerical calculations
3. input data from transducers...
Homework Statement
Requirements: http://i.imgur.com/2WKyhto.png
Homework Equations
2(L * W + L * H + W * H)
SA = (2 * pi * radius * height + 2 * pi * radius^2)
height = (volume)/(pi * radius^2)
The Attempt at a Solution
Code link: http://pastebin.com/sKFEGN0C
I need to implement the following pseudocode in Python:
N=5 #where N is number of years
For (rate = 0.05, rate <= 0.15, rate = rate + 0.05)
For (principal=10000, principal <=15000, principal=principal+1000)
simple = principal * (1 + rate * N) #where N is number...
Hello people i know this program is better to use on Linux, but for personal reasons i can't change to Linux OS. So I'm having a little problema on how to use python and install the modules of astropy, ipython, I've already installed pip but i have a error on python shell that says: Error...
I have been given a task to create an interpolating/extrapolating programme. I have completed the programme for linear interpolation (2 points) but now must make it usable for 3 or more points, ie a polynomial of n points. I think I have the equation in general for a polynomial as it is an...
Hello! BlueberryPi here, and I have got a question for you: is Python better than Ruby?
Background Info: Python is a strong programming language which allows GUI's to be built without much pain. It built sites like Google, You Tube, Pinterest, and DropBox.
Ruby is a flexible language which...
I am writing code in both Java and Python, and am a little confused about one thing: casting. In Python, we cast data types by using int(), str(), float(), etc. These are functions which convert one data type to its representation as another data type. However, in Java, it doesn't work like...
I have the following python code:
I need to know how to best convert this to pseudocode. On one hand, I am afraid of making it too python specific, and on the other hand, it can't be too general. For example, for the 2nd and 3rd blocks of code, how would I write them in pseudocode? What...
Hi, I'm trying to learn python for electrical engineering application. Is there any interactive website to learn this, especially the one with interactive compiler or result animation? Maybe equipped with microcontroller simulator, LED, and actuator? (if is it possible)
So far, I've tried...
Hello all, first post.
I have come here to get second opinions on the program I have written to compute the Einstein Tensor (the Riemann Tensor and Ricci Tensor). I enjoy looking for solutions to the Einstein Field Equations, however computing them by hand is not realistic. I decided to write a...
Hi,
I have to write a program in python (for school) that simulates a specific structure. I choosed saturn's rings. I've started by wrinting an N-body code. My goals are explaining the divisions in saturn rings as cassini division. I don't know if it's a great subject. The teacher told us to...
Hi, I was just wondering if there were any good resources/sites for learning to plot and solve differential equations and any other math for that matter, specifically in Python? The physics program at ASU is great but we aren't really given any class time to learn how to program, it's all on our...
Hi
After removing high frequency white noise in my INS sensor, I want to simulate low frequency noise with Burg or Yuler.
I used some functions in python to analyse the recorded data and to get parameters to use.
But the the problem is the sequences generated diverge (and take very big...
I have a friend who wrote a script for doing Runge Kutta and I didn't even know you could do that in Python. He's kind of poor at explaining stuff so I'm here to ask how one learns to do that. I'm a Physics/Comp. Sci. student who's still self teaching myself a lot of stuff. I've only taken an...
Homework Statement
So I'm currently modifying an example Symbolic Regression program that uses genetic programming, a type of evolutionary algorithm. I'm using the python deap library. Not sure if anyone on here is familiar with it, but I think that the error is more general to a misuse of...
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
This is the code for python I found (didn't create) which I believe is correct:
max = 1000
result = 0
for...
I am applying to University in January 2016 for either maths or computer science. I have taken the Gr. 12 prerequisite courses and did alright in them (calculus 89, physics 96, etc), but I feel I still do not have a solid foundation in maths to really feel comfortable going into a degree...
I've written a code which reads in an input file and extracts a number which represents a grid size, from lines in the file which can contain arbitrary characters. The extraction of the data seems to be working, but for some reason the loop executes 4 times and then moves on to the next...
I have a 2D Gaussian:
## f(x,y) = e^{-[(x-x_o)^2 + (y-y_o)^2]/(2*{sigma}^2)}##
which I converted into polar coordinates and got:
## g(r,θ) = e^{-[r^2 + r_o^2 - 2*r*r_o(cos(θ)cos(θ_o) + sin(θ)sin(θ_o))]/({2*{sigma}^2})} ##
The proof for how this was done is in the attached file, and it would...
I've been running some of my own simulations of a variation on a standard map using Verlet integration on Mathematica, and I would like to start generating maps of phase space using ~25,000 initial points. I'm currently at 1000 points using Mathematica, and each simulation takes about 15 minutes...
This seems like a fairly common technique but I'm fairly new to programming and don't quite know what the proper terms to find such an algorithm would be. In my case, it seems like a list of all possible values would approach almost a billion, and I feel like there's a quicker approach to...
Hi,
I'm trying to get how well a known function fits to a set of data. I'm not interested in the data's line of best fit or anything, I just want to know how close it is to my model. I've tried using curve_fit and linregress but neither really give me what I'm after. My data follows a...