First successful attempt at modeling the NS equations! I'm new to CFD and numerical methods in general so I'm pretty proud of it. This is a finite difference solution to the incompressible navier-stokes equations showing velocity magnitude of flow over a box. Feedback appreciated!
πŸ‘︎ 132
πŸ’¬︎
πŸ‘€︎ u/Ipingpong1
πŸ“…︎ Nov 19 2021
🚨︎ report
[Article]PARAMETRIC STUDY, MODELING, AND NUMERICAL SOLUTION OF AN INCLINED SOLAR STILL Url: https://www.dl.begellhouse.com/journals/648192910890cd0e,1caa9fbf6e1d2ced,72e813a3605a22e7.html# Doi: 10.1615/ComputThermalScien.2020026430

[Article]PARAMETRIC STUDY, MODELING, AND NUMERICAL SOLUTION OF AN INCLINED SOLAR STILL

Url: https://www.dl.begellhouse.com/journals/648192910890cd0e,1caa9fbf6e1d2ced,72e813a3605a22e7.html#

Doi: 10.1615/ComputThermalScien.2020026430

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Abhisek_Sarangi
πŸ“…︎ Dec 23 2021
🚨︎ report
Numerical solution of polynomial equations

I'm trying to count singular curves through points.

I made a program to set up those equations (say 20 variables, 16 linear equations, and 4 equations of degree 3) and I'm trying to find all approximate numerical solutions (real) (it's important I get all of them).

Sage solve method is bad since it tries to solve symbolically (in any case it gets stuck on my input).

Sympy nsolve is better, though it requires a starting point and I'm unable to generate all solutions.

Since these are polynomial equations I expect there to be a program that finds all solutions, can you help me find it? I'm only interested in real ones which should make everything easier.

Thanks for all your comments, I'll try it out

EDIT: Thanks bertini managed to do the job, hooray bertini.

πŸ‘︎ 48
πŸ’¬︎
πŸ‘€︎ u/CaesarTheFirst1
πŸ“…︎ Sep 08 2021
🚨︎ report
Fix for non-numerical solution ordering

Apparently the game sorts save files non-numerically, causing weird ordering when you have more than 10 solutions to a puzzle. This python script fixes that by renaming the save files, adding 1000 to their counters. Perhaps this can be useful for someone else too. If so, enjoy! This works well for me and should be safe enough, but use at your own risk obviously.

Just paste the code below into a python file and run it in your save directory.

# Renames Shenzhen IO save files by adding 1000 to the counter in the filename,
# if less than 1000.
# This works around the bug with non-numerical sorting of solutions in-game, 
# which results in weird solution ordering once you have more than 10 for a 
# puzzle.
#
# Run this in your Shenzhen IO save directory.
# Requires Python 3.4+, I think.
#
# Just rerun it after starting a new puzzle to rename the new save files.
# Once you have at least one solution for a puzzle the game will name the next 
# solutions incrementally.

from pathlib import Path

for filename in Path(".").glob("*.txt"):
    stem, _, number = filename.stem.rpartition("-")
    if not number.isnumeric() or int(number) > 999:
        continue

    new_filename = f"{stem}-{int(number) + 1000}.txt"

    if Path(new_filename).exists():
        print(f"Target file already exists, skipping: {filename} -> {new_filename}")
    else:
        filename.rename(new_filename)
πŸ‘︎ 9
πŸ’¬︎
πŸ‘€︎ u/_Fluff_
πŸ“…︎ Nov 09 2021
🚨︎ report
Is there a proof of the existence of at least one root with integer part 1/2? What is the approximation error of the Numerical solutions? Do you accept this number as a Zeta root?

https://preview.redd.it/drgnv17ovtr71.png?width=1921&format=png&auto=webp&s=e1e9a0d40333f8cde4542d8edfc682022b45d9cf

https://www.wolframalpha.com/input/?i=Zeta%28-2.000000000000000159273069185+%2B+2.400185922250348008736784774%C3%9710%5E-23+i%29

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Quijadadp
πŸ“…︎ Oct 06 2021
🚨︎ report
Problems with Numerical Solution

Hello,

I've been having current issues with the numerical solver in MatLab, and I don't understand why. I'm currently solving a problem about the maximum range of a projectile launched at 45 degrees with a bunch of initial conditions to make it all simple. However, when. create the equation, plug in the values, and try to use the solve() function, it spits out a mess of values that I :

a) Don't know what they mean.

b) Don't make sense as I know what the final answer should be and it shouldn't be this confusing.

I've looked over it a multitude of times and I still can't figure what the issue is. The answer I should be getting is approximately 0.491. When I put into Desmos or another graphical solver I get the correct values, but not with MatLab for some reason.

See below my code, Problem 22:

%% Problem 22

clc;clear;

% Part A

O = pi/4; % Launch Angle, radians

g = 1; % Gravity m/s^2

V_o = 1; % Initial Velocity

V_xo = @(x) V_o*cos(x); % Initial X-component of Velocity

V_yo = @(x) V_o*sin(x); % Initial Y-component of Velocity

V_ter = 1; % Terminal Velocity

T = V_ter/g; % Tau, Time Constant

R_vac = @(Vxo,Vyo) (2*Vxo*Vyo)/g;

Rm_vac = R_vac(V_xo(O),V_yo(O));

display(['The maximum range for a projectile in a vaccuum is ' ...

num2str(Rm_vac)])

% Part B

syms R

R_max = @(Vxo,Vyo,Vt,T) ((Vyo + Vt)/Vxo)*R + Vt*T*log(1 - (R/Vxo));

R_max(V_xo(O),V_yo(O),V_ter,T);

RmaxSol = solve(R_max(V_xo(O),V_yo(O),V_ter,T) == 0,R);

Please help, I don't know how I'm supposed to fix it.

EDIT:

Returning R_max with the conditions makes the numbers absurdly big as well, which doesn't make sense.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/LudicrousMilk
πŸ“…︎ Oct 08 2021
🚨︎ report
Hi everyone, sorry if this is beyond the scope of sub as it's numerical methods - not analytical. But I'm looking at the solution to this question paper and I'm not sure I follow. Specifically where they got y'(0) = 4. Any help appreciated!

https://preview.redd.it/ni73icboglf71.png?width=1044&format=png&auto=webp&s=8daee73775d376ac144dbfd0d60bbb988ea3b2d4

πŸ‘︎ 6
πŸ’¬︎
πŸ‘€︎ u/Aunty_Polly420
πŸ“…︎ Aug 05 2021
🚨︎ report
2D Schrodinger Numerical Solution in Python! This is based on both Hudsmith's and CreativeUsername's extremely clever solutions from this forum. Emphasized here is how to represent a 2D state as a vector, how the Kronecker sum can help us express the Hamiltonian, and why scipy.sparse is so nice youtube.com/watch?v=DF1Sn…
πŸ‘︎ 699
πŸ’¬︎
πŸ‘€︎ u/JackStrawng
πŸ“…︎ Apr 03 2021
🚨︎ report
Could someone help me in understanding this exercise (numerical differentiation)? I don't understand how in the solution it equals to 6.80

The distance x of a runner from a fixed point is measured (in metres) at intervals of half a second. The data obtained are

t 0.0 0.5 1.0 1.5 2.0
x 0.00 3.65 6.80 9.90 12.15

Use central differences to approximate the runner’s velocity at times t = 0.5 s and t = 1.25 s.

Solution

Our aim here is to approximate x'(t).

The choice of h is dictated by the available data given in the table.

Using data with t = 0.5 s at its centre we obtain

x'(0.5) β‰ˆ x(1.0) βˆ’ x(0.0) 2 Γ— 0.5 = 6.80 m sβˆ’1 .

Data centred at t = 1.25 s gives us the approximation

x'(1.25) β‰ˆ x(1.5) βˆ’ x(1.0) 2 Γ— 0.25 = 6.20 m sβˆ’1 .

Note the value of h used.

A screenshot if it helps: https://ibb.co/WHTtrLf

πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/POIS_hell
πŸ“…︎ Jul 13 2021
🚨︎ report
When an intense laser field hit a bound electron - a numerical solution of the time dependent Schrodinger equation youtu.be/_WNnG4sXDOU
πŸ‘︎ 25
πŸ’¬︎
πŸ“…︎ Jun 05 2021
🚨︎ report
How much error would this practice introduce to a numerical simulation/solution

Let's say I have a system of equations that should be solved simultaneously at every timestep, t=t0+dt

For example:

A = B*(C^2);

C = B + A;

B = C/A

where A, B, and C are all change at each timestep.

But let's say instead of solving for A,B,C simultaneously, I use results from the previous timestep instead:

A = B_previous*(C_previous^2) or C = B_previous + A_previous.

This is possible since I know the initial values at the very beginning. Is there a term for this, or is it just a horrific oversimplification that is unheard of?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/zenzof
πŸ“…︎ Jul 16 2021
🚨︎ report
How do you guys set up Schroedinger PDEs for numerical solutions?

I'm just trying to teach myself the finite difference method for solving PDEs and wondered how you might apply it to Schroedinger's equation? I know the boundary conditions are a bit different to those applied to the heat equation because they apply some normalizable creteria instead but not sure how that translates into a numerical formula boundary condition. Any thoughts?

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/kiwiheretic
πŸ“…︎ Aug 07 2021
🚨︎ report
Heat transfer: explicit and implicit Euler's methods to obtain a numerical solution.

Hi,

I have been experimenting a bit with an explicit and implicit Euler's methods to solve a simple heat transfer partial differential equation:

βˆ‚T/βˆ‚t = alpha * (βˆ‚^2T/βˆ‚x^2)

T = temperature, x = axial dimension. The initial condition I used is for x = 0, T = 100 Β°C. And the boundary condition at the end of the computational grid: for T**(x = L) =** T**(x=*****L-***1), where L is a length of the computational grid -> the last and the and next-to-last values of temperature are the same.

Would some be willing to look at my code (I am not a MATLAB guy, but I try to learn) whether my implementation of implicit method is correct.

My thoughts:

Explicit method (works fine): Every values of T are calculated by T1(i) + heat_coefficient*((T1(i+1)-2*T1(i)+T1(i-1))/dx^2)*dt, except for the first and the last value which are specified by the I.C. and B.C., respectively.

My question:

Implicit method: At first, I create a tri-diagonal matrix MAT
, which defines a relationship between the values in the next time line (n+1). In the case of an implicit method, I cannot write I.C. and B.C. exactly, and therefore I save them on the β€œRight side of the equation”, i.e. pS(i) = -(T2(i)*dx^2)/(heat_coefficient*dt);

By this, I express all the values in one time line (n) and after that, I continue in the following time line (n+1).

If I put I.C. or B.C. into the β€œRight side of the equation”, the results become very sensitive to any change of positional (dx) and time (dt) step. Behavior of the temperature function is therefore wrong: the curves of a temperature should converge to the same values after certain time (if the time goes to infinity), however, my curves converge to a different values (and randomly change based on dx and dt).

How do I achieve to start at a temperature of 100 Β°C, such that after an β€œinfinitely” long time, all of the temperature curves converge to 100 Β°C?

Should the values of I.C. and B.C. be put into a tri-diagonal matrix - e.g., if I have matrix with dimensions [N,N], then I specify I.C. for point [1,1], and B.C. for point [N,N]? (Unfortunately, it did not work properly when I tried)

Also, my implementation of the tri-diagonal matrix is probably not very nice, but it works.

πŸ‘︎ 20
πŸ’¬︎
πŸ‘€︎ u/iBo0m
πŸ“…︎ Mar 31 2021
🚨︎ report
Numerical solution SIR model using 4RK

I’m having some trouble with part b) of this problem. For part a) I have applied the 4th order RK method in python in order to get the peak time, max number of infected people... Any help will be appreciated , thanksπŸ™πŸΌπŸ™πŸΌπŸ™πŸΌπŸ˜­

It says:

a) One person, highly contagious with a new influenza virus, enters a small community that has a population of 1000 (N) individuals that are susceptible to the infection. The virus epidemic spreads quickly and eventually infects all susceptible individuals. The rate constants for this epidemic are

π‘Ž=0.005(π‘π‘’π‘Ÿπ‘ π‘œπ‘›)^βˆ’1(π‘€π‘’π‘’π‘˜)^βˆ’1

𝑏=1/(π‘€π‘’π‘’π‘˜)^βˆ’1

Integrate the differential equations using an explicit RK method and determine the following:

How many weeks does it take for this epidemic to reach its peak?

What is the maximum number of persons sick at the peak of the epidemic?

In how many weeks will the epidemic subside (when less than 5% of the susceptible population is still infected)?

b) The basic reproduction number is usually denoted by R0 . For this model, the basic reproduction number or contact number for the disease is

R0=π‘Žπ‘/𝑏

What is the maximum value of R0 in order to have a maximum of 10% of the population infected at any time?

In how many weeks will the epidemic subside in this case?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/paumga
πŸ“…︎ May 05 2021
🚨︎ report
[Electromagnetism]By making a numerical solution to Laplace's equation using relaxation methods, I obtain this plot for 2 finite paralell plate capacitors (left V=10 right V=-5) inside a grounded box of the dimensions of the axis. The equipotential line of V=0 in red moves to the right, why is that?
πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/geduq
πŸ“…︎ Apr 26 2021
🚨︎ report
Comparison of numerical solution of a quantum particle and classical point mass bouncing in gravitational potential (ground is on the left)
πŸ‘︎ 2k
πŸ’¬︎
πŸ‘€︎ u/tpolakov1
πŸ“…︎ Jan 23 2020
🚨︎ report
2D Schrodinger Numerical Solution in Python! This is based on both Hudsmith's and CreativeUsername's extremely clever solutions from r/Physics. Emphasized here is how to represent a 2D state as a vector, how the Kronecker sum can help us express the Hamiltonian, and why scipy.sparse is so nice youtube.com/watch?v=DF1Sn…
πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/JackStrawng
πŸ“…︎ Apr 04 2021
🚨︎ report
GLTR : What to do when the solution of the tridiagonal subproblem isn't available due to numerical errors ?

I'm using the generalized Lanczos trust-region method (GLTR) to solve a trust region subproblem. Each tridigonal subproblems are solved via the MorΓ©-Sorensen method.
Sometimes at a given iteration, the method fails at finding a sufficiently accurate solution to the tridiagonal subproblem.
What is the standard course of action in this case ?

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/hoffnoob1
πŸ“…︎ Mar 05 2021
🚨︎ report
2D heat equation solution (numerical PDE solver) v.redd.it/jwen2dbd04k51
πŸ‘︎ 18
πŸ’¬︎
πŸ‘€︎ u/arfamorish
πŸ“…︎ Aug 30 2020
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.