Question

Write a computer code to do the mode summation for a string with a length of...

Write a computer code to do the mode summation for a string with a length of 20, wave velocity of 3. The string was plucked at time 0 by a source at position 8. The source function is ?=exp[−(?+?)./4].

1a. Show the mode summation at time 1,2, 3 for the first 40 modes.

1b. Show the mode summation at time 1, 2, 3 for the first 80 modes.

You need to have sufficient comments in your scripts. It is not required, but is preferred to use Matlab to make a movie of the wave propagation.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
program synt_seis_strings
    implicit none
    real, parameter :: pi = 4*atan(1.0)
    real :: stln,vel,xsrc,xrcvr,tseis,dt,tau,npiL,srctm,rcvrtm,wn,Fwn,spctm,coswt
    integer :: i,n,j
    integer, parameter :: nmode=200    !number of modes (nmode)
    integer, parameter :: nt=100    !number of time steps(nt)
    real(kind=16), dimension(1:nmode) :: Uxt
    real(kind=16), dimension(1:nt) :: Umode
    character*12 :: filename

    
    print *, 'Enter the string length (ex: 1.0):'
    read *, stln

    print *, 'Enter the wave speed: (ex: 1.0):'
    read *, vel
    

    print *, 'Enter the position of the source (in m) (ex: 0.2) :'
    read *, xsrc
    
    print *, 'Enter the position of the receiver (in m) (ex: 0.7) :'
    read *, xrcvr

    print *, 'Enter the duration of the seismogram (in sec) (ex: 1.25) :'
    read *, tseis

    dt=tseis/nt    !time step in sec
    tau=0.02    !source shape term

    
    do 5 i=1,nt
        Uxt(i)=0.0
    5 continue
    do 10 n=1,nmode
        npiL=n*pi/stln
        srctm=sin(npiL*xsrc)    !source term
        rcvrtm=sin(npiL*xrcvr)    !Receiver term
        wn=n*pi*vel/stln    !mode frequency
        Fwn=exp(-((tau*wn)**2)/4)    !weighting factor of different frequencies

        spctm=srctm*rcvrtm*Fwn        !space term
        
        do 15 j=1,nt
            coswt=cos(wn*dt*(j-1))    !time term
            Uxt(j)=Uxt(j) + coswt*spctm    !displacement
        15 continue
    
    10 continue
        open(unit=1,file='seism.dat')
        write(1,'(f6.2,f12.6)') (dt*(j-1),Uxt(j), j=1,nt)    !writing the displacement
        close(1)
        
        
    stop
end program synt_seis_strings
Add a comment
Know the answer?
Add Answer to:
Write a computer code to do the mode summation for a string with a length of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a computer program to solve a tri-diagonal system of equations. The code should do the...

    Write a computer program to solve a tri-diagonal system of equations. The code should do the following 1. It should be general for an n-dimensional system 2. It should have comments in the code explaining the stages of algorithm 3. use two (10*10) examples to show the performance requires usage of c++ and/or MATLAB

  • COULD YOU PLEASE HELP ME************************** write a better mode computation function that uses the ideas in...

    COULD YOU PLEASE HELP ME************************** write a better mode computation function that uses the ideas in the word file and improves on the mode computation function in the cpp file. ===========source.cpp #include <ctime> #include <iomanip> #include <iostream> #include <string> #include <random> using namespace std; default_random_engine e(static_cast<unsigned>(time(NULL))); void fill(int a[], int size, int value) { for(int i = 0; i < size; i++) a[i] = value; } void randomFill(int a[], int size, int lb, int up) { uniform_int_distribution<int> u(lb, up); for(int...

  • MATLAB question I need the code exactly as you would write it in MATLAB. thank you...

    MATLAB question I need the code exactly as you would write it in MATLAB. thank you 1. Consider a Gaussian solution of the traveling-wave form ψ(z,t)-exp(-a(z-vt)2). The parameter values are a 1, 2. (a) Explain the physical meaning of these parameters (eg. what would happen if we took a = 10 instead?) Determine the direction of propagation of this solution: Is it traweling to the left or to the right? (2pts) (b) Write a Matlab code to plot the Gaussian...

  • Write a computer code that: 1. (5 points total) Takes as input: a. (1 point) A...

    Write a computer code that: 1. (5 points total) Takes as input: a. (1 point) A position vector (in km) and a velocity vector (in km/s) in ECI coordinates b. (1 point) An initial time t (in secs) c. (1 point) A later time t2 (in secs) d. (1 point) The tolerance Ar e. (1 point) The tolerance AA 2.(5 points total) Outputs the input data with labels and units (as appropriate) 3. (39 points total) Calculates the following: a....

  • please answer all parts and code thanks . - PART 1-Introduction to Sorting, 21 points Use...

    please answer all parts and code thanks . - PART 1-Introduction to Sorting, 21 points Use this array of integer for the problems 1A, 1B, and 1c: 9 57 8324761 Each of these problems is worth 3 points A. Show the contents of the array each time a selection sort changes it while sorting the array into B. Show the contents of the array each time an insertion sort changes it while sorting C. Show the contents of the array...

  • Signals and System: MATLAB code provided? Begin with the MATLAB script named lab4.m as follows. You...

    Signals and System: MATLAB code provided? Begin with the MATLAB script named lab4.m as follows. You will modify this example code to cover each of the parts of this lab. You must always carefully document and include appropriate comments in any MATLAB code. & starting point for Lab#4 % LAPLACE TRANSFORM %---------- clear all; close all; -------------------- s = tf('s'); sys = 1/(5+1); & define H(s) for a dynamic system named sys ---------------- figure(1); bode (sys); % plot magnitude and...

  • How do i write the pseudocode for this java code? First, write out pseudocode, and then create a program to help you by accomplishing the following tasks: :  Use command line interface to ask the use...

    How do i write the pseudocode for this java code? First, write out pseudocode, and then create a program to help you by accomplishing the following tasks: :  Use command line interface to ask the user to input the following. ○ How many apples are on hand ○ How many apples should be in stock ○ How many oranges are on hand ○ How many oranges should be in stock  Perform an operation to determine how many of...

  • Write a program that reads a string from the keyboard and tests whether it contains a...

    Write a program that reads a string from the keyboard and tests whether it contains a valid time. Display the time as described below if it is valid, otherwise display a message as described below. The input date should have the format hh:mm:ss (where hh = hour, mm = minutes and ss = seconds in a 24 hour clock, for example 23:47:55). Here are the input errors (exceptions) that your program should detect and deal with: Receive the input from...

  • Write a C++ code based this question n this assignment you will create three additional functions...

    Write a C++ code based this question n this assignment you will create three additional functions for each one of the data structures created in class. You will be provided with a header file which you will modify and a demo program for each data structure. If your functions are implemented correctly the demo programs should compile and execute correctly. Part 0 (Comments) 1. Over the course of the semester we have discussed comments for each data structure. Please add...

  • Write the code in C language. Computer communication networks sometimes have noise on them, which can...

    Write the code in C language. Computer communication networks sometimes have noise on them, which can corrupt data being transmitted. It is the responsibility of the computers communicating to confirm data is transmitted accurately. One method to do this is to calculate a checksum of the data and transmit the checksum along with the data to ensure accuracy. In C, we can compute a checksum simply by summing the integer ASCII codes in the message and finding the remainder of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT