Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask MATLAB Expert

1 Goals

To write code to

- parse and load data files and deal with missing data,
- implement a more complex program involving multiple function calls.
- output nicely formatted results and figures summarizing your analyses.


2 Background - the theory governing the electrical condutivity of natural waters

Certain basic properties of lakes and oceans are important to understanding how they "work". These include tem- perature (i.e., the heat content), and the amount of dissolved matter (the salt content). One measure of the dissolved matter is the VOLUMETRIC SALINITY S, which is the total amount of dissolved stuff measured in units of grams per liter of solution. Seawater has salinities of 2-35 g/l, but even fresh water in lakes (and our drinking water) has small amounts of dissolved material (typically .1-1 g/l in most lakes, but sometimes up to 70 g/l or more in so-called
saline lakes, which usually are in hot dry places with a lot of evaporation)∗.

Temperature is pretty easy to measure, but the salinity is not. In general, the dissolved matter consists of a large number of different ions, each of which may require specialized chemical analysis techniques to measure properly. However, we can get a rough idea of the concentration of charged ions in solution by measuring the electrical
conductivity of the water at a fixed reference temperature (usually chosen to be 25?C). This is a relatively easy thing
to measure. The salinity in g/l and conductivity κ in mS/cm ("milli-Siemens per cm") are related by a factor α such that
S = ακ (1)
where this factor α is specific to a particular lake (i.e., a particular ionic composition), but is usually around 0.5-1. In this lab we are going to write to code to try and predict the α ratio a bit more accurately for lakes with a known chemical composition.

Conductivity is related to the speed at which electrical charges (attached to ions) move through the fluid (the "elec- trical current") when a voltage is applied. The total current is the combined effect of the current that arises from the effects of each ion. Let us assign each type of ion to an index i = 1 . . . N . Since different ions have differ- ent sizes, masses, and electrical charges they each have their own INFINITE DILUTION IONIC EQUIVALENT† CONDUCTIVITY λo. Then the total measured conductivity κ would be the sum of these:

where zi is the charge on the ion and ci is its concentration in MOLES PER LITER SOLUTION. For example,zi = 1 for Na+ (sodium), and zi = -2 for SO2- (sulfate). Note that the volumetric salinity can also be calculated

where Mi is the MOLAR MASS of the different ions (see Table 1), and ci is again the concentration.However, when there are lots of other ions around, their electric fields can "screen" each other, so that the actual ∗Since volume changes with temperature, assume that we are dealing with volume at a reference temperature of 25?C in this assignment. † In this context, the word EQUIVALENT means that the value is per charge, rather than per 


1694_1.png

(Note - equation (5) is actually good only for pretty weak ionic concentrations. At higher salinities the dependence on I becomes more complicated, and other effects in addition to this 'screening' also become important in many natural waters, but we are going to ignore that here).

Although natural waters (i.e. lake, river, and seawaters) contain almost everything at some concentration, most of the dissolved material is composed of 7 different ions, the so-called MAJOR IONS. These are listed in Table 1, along with their molar masses, charges, and the parameters for calculating their equivalent conductivities.

One final issue is that ions are not present in arbitrary amounts. Since you don't get electrocuted when you touch water (!), the number of positive charges must EXACTLY equal the number of negative charges. That is, the CHARGE BALANCMUST equal zero (exactly) for any water containing ions. One advantage of this is that if you have a measurement that doesn't include one of the major ions (typically bicarbonate, or HCO-), you can estimate this by adding up the charges of the other ions and then setting the concentration of HCO- to balance the excess of positive charge.
Another advantage is that you can calculate the charge balance as a check value on the data, to see if it makes sense (or whether an error has crept into the values).


3 The assignment - an overview

The assignment is basically concerned with the writing of a number of functions which can implement the conduc- tivity theory described above. These functions will then be called by a program which will load data files containing the composition of a number of natural waters and make some plots comparing them. The organization of the functions is up to you, but one way of doing this is to have


• assign2.m containing the "driver" code which reads water composition data and makes plots
• cond.m containing the function cond, and subfunction istrength. This will compute the conductivity for a given chemical composition, with the subfunctions computing the ionic strength of the solution.
• chargebal.m containing the function chargebal which will compute the charge balance for a given composition.
• salinity.m containing the function salinity which will compute the salinity of a given composition.
• loadcomp.m containing the function loadcomp which will load data in a given filename, and return a row vector containing the composition.

Some other hints are:

• Since there are 7 different ions, you could use a different variable name for each in your code. However, it is more efficient to store their data in row vectors, where each column represents data for a particular ion.
• Avoid "hard-wiring" numbers into your code. Keep the (fixed) data for molar masses, ionic charges, and so on in row vectors specified ONCE. This makes it much easier to modify your program to take into account changes in the molar masses, number of ions in the compositions, or other factors.
• The simplest starting point is to write code that can load in a composition, and compute its salinity and charge balance. Missing data in composition files is specified by a -999 value. Salinities of compositions with missing data should return an error. Charge balance calculations should ignore missing data (i.e. make the calculation assuming a value of zero for the missing data).
• Above all, resist the tendency to start writing code BEFORE you REALLY understand WHAT you have to code. IN PARTICULAR, use pencil and paper to specify the INPUTS and OUTPUTs of all functions, and specify WHERE (in what functions) the different kinds of information in Table 1 is required.


4 The assignment itself

1. Read ALL the background, and ALL parts of the asignment (I wasn't kidding in the hints).
2. Begin with seawater. Load the seawater composition seawater.txt, and compute its salinity (check value 35.12978962193 g/l, perhaps varying in the last decimal place depending on details of the computation) and conductivity (check value 46.86864157996 mS/cm). The composition of seawater at other salinities can be found by scaling the ionic concentrations by a constant factor. For example, IF the salinity was 40 (it is not), then you could find concentrations for a salinity of 10 by scaling with a factor of 10/40.
• PLOT: the conductivity (on y axis) for salinities of 0.1 to 35 g/l (on x axis).Take enough steps between
0.1 and 25 so that the curve LOOKS SMOOTH when plotted.
• PLOT: the factor α (on y axis) for salinities of 0.1 to 35 g/l (on x axis). Make both of these plots as subplots, one above the other, with the x axes aligned.
3. Seawater is mostly made up of sodium and chloride (i.e. table salt). If you take a solution of ONLY Na+ and
Cl- (i.e. with the amounts of all other ions set to zero), what is α for salinities of 0.1 to 35?
• PLOT: Add the conductivity and α curves to the two from the previous section.
• TEXT: How much of a difference does approximating seawater with a sodium chloride solution make in the conductivity at a salinity of 10 g/l (i.e. what is the percent error)?

4. Read in the compositions of world average freshwater (worldriver.txt), Mahoney Lake in the interior of British Columbia (mahoneylake.txt), and Mono Lake in California (monolake.txt). Mono and Mahoney Lake are SALINE lakes. In all cases the bicarbonate concentrations are not known. Using the charge balance, estimate what these concentrations might be (i.e. so that the overall charge balance is zero) and then compute the conductivities of these waters.
• PLOT: A figure that will allow you to compare the relative composition of seawater and all 3 other water types. Be creative!
• TEXT: The dominant positive ion for seawater is Na+, and the dominant negative ion is Cl- (that is, these have the greatest concentrations in mol/l). Using your figure, determine (and state) the dominant positive and negative ion for the other water types.
• OUTPUT: A table containing the name of the lake, the input or calculated bicarbonate concentration, the conductivity of the water, and the α ratio. Use fprintf!


5 HAND IN AS HARDCOPY 

• all items requested as PLOT in the form of a plot. Pay attention to the quality of the plots as part of your mark will involve plot quality as well the correctness of the results.
• all items requested as TEXT in the form of written text
• all items requested as OUTPUT in the form of a printed file
• a printout of your assign2.m script and the other functions you write.
• Electronically submit the partner.m file described next. Not handing this in will result in marks being deducted!

ASSIGNMENTS CAN BE DONE WITH OTHERS, AS PER THE LABS. Each person must hand in their own as- signment, but you MUST document the degree of collaboration. This will be done by submitting a file partner.m via VISTA. The file will contain the following lines:

partner.name='YYYYYY'; partner.stu='ZZZZ'; partner.collab='AAAA'; Time_spent= XX;

where the .collab string is a phrase like 'checked answers only', 'worked whole assignment together', or some other brief statement that describes your collaboration.

If you worked alone, you must STILL submit the file (we would like to know how many people worked alone!) but you can write the word NONE for all three partner information strings, or something like 'various people about minor issues', or...

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M91868581
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in MATLAB

Suppose that a student has the option of enrolling for a

Suppose that a student has the option of enrolling for a single elective during a term. The student must select a course from a limited list of options: "English, " "History, " "Biology, " "Computer, " or "Math." Constru ...

Assignment -we have daily gridded rainfall data of 40 years

Assignment - We have daily gridded rainfall data of 40 years and structure of the dataset is like below; Lat = [6.5:0.25:38.5]; Lon = [66.5:0.25:100]; Rainfall (135x129x365x40) (Lon, Lat, days, years). Now, we looking fo ...

Assignmentq1 find the laplace transforms of the following

Assignment Q.1 Find the Laplace transforms of the following functions: (a) t 2 + at + b and (b) sin(2nΠt/T) Q.2 Find f (t) for the following F(s) = α[ f (t)]. (i) 5/(s + 3), (ii) 1/s 2 + 25, (iii) 1/s(s+1) Q.3 Find the L ...

Assignment -data is given on which want to do computational

Assignment - Data is given on which want to do computational production planning using Metaheuristic MATLAB Programming: 1) Ant Colony Algorithm on both Partial and Total Flexible Problem. 2) Bee Algorithm on both Partia ...

Question - verify the attached paper with matlab and get

Question - Verify the attached paper with matlab and get all the results in the paper and explain step by step the matlab code. Paper - Improving Massive MIMO Belief Propagation Detector with Deep Neural Network. Attachm ...

Assignment details -need to write a code for connecting

Assignment Details - Need to write a code for connecting segments (Lines) a special case of TSP. The problem is to connect lines in 2d/ 3d space with path obstructions. Can you help me write the code for this? Hope you m ...

Assignmentafter the success of your robo-advice venture you

Assignment After the success of your robo-advice venture you decide to explore alternative sources of profitability for your company. You realize that Australian investors are often forced to chose between expensive acti ...

Recitation problems -1 determine the highest real root of

Recitation Problems - 1. Determine the highest real root of f(x) = 2x 3 - 11.7x 2 + 17.7x - 5 using the Newton-Raphson method with at least four iterations. Start with an initial guess of x 0 = 3. 2. Determine the real r ...

Question 1 manipulate spectral imagehyperspectral images

Question 1. Manipulate spectral image Hyperspectral images can be seen as a generalisation of normal colour images such as RGB images. In a normal RGB colour image, there are 3 channels, i.e. channels for red colour, gre ...

Assignment -matlab codes and simulated model in

Assignment - Matlab codes and simulated model in simulink/matlab and truetime. 1. Matlab codes and simulink model for pid controller optimization using particle swarm optimization (PSO) my plant is integer order 1000/(s^ ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As