Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C PROGRAMMING QUESTION. Hi i am coding up a program that solves the 1D linear convection equation in C. I am running into some issues

C PROGRAMMING QUESTION. Hi i am coding up a program that solves the 1D linear convection equation in C. I am running into some issues in my final nested loop which applies the update equation. (see code below). I dont know what going wrong. I have the problem coded up and working in python i also have attached that code below for reference. I followed that as psudeo code but my C program does not work as planned. Can anyone fix my C code. I would appreciate it a lot.

This is the C code

image text in transcribed

THIS IS THE WORKING PYTHON SCRIPT

image text in transcribed

# include # include # include # include int main() El //eqyation to be solved ID linear advection -- du/dt + c(du/dx) = 0 //initial conditions u(x,0) = 10 (x) //after discretisation using forward difference time and backward difference space //update equation becomes u[i] = 10[i] C * dt/dx * (u0[i] - ui 1]); int nx = 41; /um of grid points double dx = 2.0 / (nx 1.0); //magnitude of the spacing between grid points int nt = 25;/t is the number of timesteps double dt 0.25; //the amount of time each timestep covers int c = 1; //assume wavespeed //double uo_array: // set up our initial conditions. The initial velocity u_0 //is 2 across the interval of 0.5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions