I have a sample fortran code I would like to show here:
SUBROUTINE CALHEAT(ISTL_)
! DESCRIPTION:
!! # details
!> Subroutine CALHEAT takes the information from the atmospheric boundary
!> file and the wind forcing file and calculates the net heat flux across
!> the water surface boundary.
!
! The heat flux terms are derived from a paper by Rosati
! and Miyakoda (1988) entitled "A General Circulation Model for Upper Ocean
! Simulation". The heat flux is prescribed by term for the following
! influxes and outfluxes:
!
! - Short Wave Incoming Radiation (+)
! - Net Long Wave Radiation (+/-)
! - Sensible Heat Flux (convection -)
! - Latent Heat Flux (evaporation +/-)
!
! Two formulations of the Latent Heat Flux are provided. The first is from
! the Rosati and Miyakoda paper, the second is an alternate formulation by
! Brady, Graves, and Geyer (1969). The second formulation was taken from
! "Hydrodynamics and Transport for Water Quality Modeling" (Martin and
! McCutcheon, 1999). The Rosati and Miyakoda formulation will have zero
! evaporative cooling or heating if wind speed goes to zero. The Brady,
! Graves, and Geyer formulation provides for a minimum evaporative cooling
! under zero wind speed.
!
! MODIFICATION HISTORY:
!! #author
!> Date Author Comments
!
!
!! # param[in]
!> VARIABLE LIST:
!>
!> CLOUDT = Cloud cover (0 to 10)<BR>
!> HCON = Sensible heat flux (W/m2)<BR>
!> HLAT = Latent heat flux (W/m2)<BR>
!> HLWBR = Net longwave radiation (atmospheric long wave plus back
!> radiation, W/m2)<BR>
!> SOLSWRT = Short wave incoming radiation (W/m2)<BR>
!> SVPW = Saturation vapor pressure in mb based upon the water surface
!> temperature<BR>
!> TATMT = Temperature of air above water surface (deg C)<BR>
!> TEM = Water temperature in cell (deg C)<BR>
!> VPA = Vapor pressure of air at near surface air temperature (mb)<BR>
!> WINDST = Wind speed at 10 meters over cell surface (m/s)<BR>
!--------------------------------------------------------------------------------------------------
I want to display author, details, and parameters using deoxygen. However, doxygen only outputs the parameters. Can anyone point out what I did wrong here ?
The sample output is given below:
Thanks.
Doxygen use a special command. The complete list can be found here
For example
\author { list of authors }
\param [(dir)] <parameter-name> { parameter description }
For your code, try this:
\author Author name
\param [in] CLOUDT Cloud cover (0 to 10)
\param [in] HCON Sensible heat flux (W/m2)
\param [in] HLAT Latent heat flux (W/m2)
\param [in] HLWBR Net longwave radiation (atmospheric long wave plus back radiation, W/m2)
\param [in] SOLSWRT Short wave incoming radiation (W/m2)
\param [in] SVPW Saturation vapor pressure in mb based upon the water surface temperature
\param [in] TATMT Temperature of air above water surface (deg C)
\param [in] TEM Water temperature in cell (deg C)
\param [in] VPA Vapor pressure of air at near surface air temperature (mb)
\param [in] WINDST Wind speed at 10 meters over cell surface (m/s)
You have to write your doxygen specific information before the SUBROUTINE command! See the doxygen manual for more information.
Related
I have three recordings of a signal taken with an array of three hydrophones (one sound source).
I would like to estimate the source localization using the time of arrival differences for the three recordings. In Matlab, I started the following, by estimating the time of arrival differences with the GCC-PHAT algorithm (Generalized cross-correlation):
[sig1, fs] = audioread('signal1.wav');
sig2 = audioread('signal2.wav');
sig3 = audioread('signal3.wav');
refsig = sig1;
[tau_est, R, lags] = gccphat([sig2,sig3],refsig, fs);
disp(tau_est * fs)
It gives me the time of arrival differences of signals 2 and 3 compared to signal 1 (tau).
Now I would like to get the direction of arrival estimates (DOAs) and proceed with triangulation to assess source position.
Any help will be greatly appreciated!
Some additional information is needed to convert the time-of-arrival-difference estimates to directions of arrival:
Spatial coordinates of each mic / hydrophone in the array.
Speed of sound. Speed of sound in seawater varies significantly with temperature, salinity, and depth; see this Wikipedia article for an empirical formula.
Once you know this, use equation (1) from
https://people.engr.ncsu.edu/kay/msf/sound.htm to estimate the angle of arrival θ for each mic pair:
θ = sin⁻¹(speed_of_sound * time_difference_of_arrival / distance_between_mics)
A limitation is that the angle of arrival estimated from a single mic pair has front-back ambiguity. For instance an angle at θ = 30 degrees would have the same time difference of arrival as θ = 150 degrees. You can think of the sin⁻¹ inverse function as multivalued to represent this ambiguity. Also, keep in mind that the formula derivation assumes plane wave propagation from a source at an infinite distance, and it ignores shadowing and diffraction effects around the mic, so obviously there is some inaccuracy. But it is simple and often works decently well.
From there, you can combine angle estimates from the three mic pairs to triangulate the source position.
I am calculating the needed mass flow from a source to heat up water from 10°C to 35°C from the heat demand at any given moment.
Introducing this model to my simulation increased the simulation time a lot!
model m_flow_calc
"A simple model to calculated the primary mass flow needed to heat up space heating water "
import SI = Modelica.SIunits;
parameter SI.Temperature T_SHW_out = 30+273.15 "Temperature of the space heating water supply temperature";
parameter SI.Temperature T_SHW_in = 10+273.15 "Temperature of the space heating water return temperature";
Modelica.Blocks.Interfaces.RealInput Q_demand;
equation
m_flow =-Q_demand/(4120*(T_SHW_out-T_SHW_in)); //"Calculating the primary mass flow for a given Heating demand to heat the space heating water to the set temperature"
end m_flow_calc;
With the calculated mass flow a boundary draws the mass flow through a heat exchanger. The Temperature after the HEX is then carried over to another boundary that "pushes" out the same mass flow like in the first boundary.
Is there something i am missing that is slowing down the simulation?
I am trying to develop a mathematical method to calculate the
pressure field on offshore structures.
We are given the resultant force on the structure F, and a pressure
profile model pi = p0 dot(ni,nF) that our solution should follow. Where:
{pi}_{i=1}^{Nel} are the pressures defined in the elements of the structure (see figure);
ni are the outward normals of the elements (dot is the scalar prod)
Ai are element areas;
nf=F/|F|;
p0 is the effective pressure of the model.
I am using an optimazition algorithm using an objective function with two terms:
PHI = \alpha * ||F-F_rec ||_2^2 + \Sum_i (p0*dot(ni,nF) - pi)^2
to get the figures I am showing. where F_rec = \sum_i pi Ai ni.
I would like to add a new term in the objective accounting for continuity in the pressure field. So far I have been thinking in a third term like:
\beta * \sum_i 1/3(\sum_{j=neig(i) (pi*dot(nj,nF) - pj*dot(ni,nF))^2})
Where \alpha and \beta are constants controlling the importance of each term in the objective.
Other possibility is that the third term accounts for the total variation of the
pressure field (or maybe pi/dot(ni,nF) field). Do you have any idea of how I can define a third term measuring the total variation in a surface like this?
Thanks a lot!
What is the fitness function used to solve an inverted pendulum ?
I am evolving neural networks with genetic algorithm. And I don't know how to evaluate each individual.
I tried minimize the angle of pendulum and maximize distance traveled at the end of evaluation time (10 s), but this won't work.
inputs for neural network are: cart velocity, cart position, pendulum angular velocity and pendulum angle at time (t). The output is the force applied at time (t+1)
thanks in advance.
I found this paper which lists their objective function as being:
Defined as:
where "Xmax = 1.0, thetaMax = pi/6, _X'max = 1.0, theta'Max =
3.0, N is the number of iteration steps, T = 0.02 * TS and Wk are selected positive weights." (Using specific values for angles, velocities, and positions from the paper, however, you will want to use your own values depending on the boundary conditions of your pendulum).
The paper also states "The first and second terms determine the accumulated sum of
normalised absolute deviations of X1 and X3 from zero and the third term when minimised, maximises the survival time."
That should be more than enough to get started with, but i HIGHLY recommend you read the whole paper. Its a great read and i found it quite educational.
You can make your own fitness function, but i think the idea of using a position, velocity, angle, and the rate of change of the angle the pendulum is a good idea for the fitness function. You can, however, choose to use those variables in very different ways than the way the author of the paper chose to model their function.
It wouldn't hurt to read up on harmonic oscillators either. They take the general form:
mx" + Bx' -kx = Acos(w*t)
(where B, or A may be 0 depending on whether or not the oscillator is damped/undamped or driven/undriven respectively).
I need to model an electric rectifier and to plot both in and out signals with MATLAB. The rectifier is made of a RC circuit which charge as fast as the voltage increases but discharges way slower so the out signal is more or less flat. It's supposed to look like that:
.
I tried to code it on MATLAB and I got this (my circuit rectifies negative voltage but same principle):
.
To get the same figure as the one from wikipedia I tried to compute the intersection between the downing exp curve (red) and the rising sinus curve (blue) so I just had to add a sin curve and a downing exp curve at right intervals to get the out signal.
Here is my code:
f=#(x)sin(2*pi*250000*x+pi/2);%oscillateur de référence
f1=#(x)sin(2*pi*250000*x);
g=#(x)exp(-x*10^4);%décharge du détecteur de crête
h=#(x)f(x)-g(x);%intersection des deux fonctions
format long;
inter=fzero(h,[3.82*10^-6,3.90*10^-6]);
y1=g(0:10^-12:inter);
y2=f(inter:10^-12:4*10^-6);
y3=sin(2*pi*250000*(0:10^-12:1*10^-6));
y=-[y3 y1 y2 y1 y2];
y4=-f1(linspace(0,8*10^-6,length(y)));
x=linspace(0,10*10^-6,length(y));%abscisse
plot(x,y,x,y4);
But why is there a gap between the curves on my figure ?
You really don't need to find the intersection points. You can reproduce the same curve with a series of nested max() calls and logical operations. Here's an example:
f=#(x)sin(2*pi*250000*x);
discharge=1e-6; %# quarter period when discharge begins
g=#(x)exp(-rem(x-discharge,(1e-5)/2.5)*10^5); %#modulo over the period to repeat.
h=#(x)max(f(x).*(x<discharge),max(f(x),g(x)).*(x>=discharge)); %# the rectified signal
y=linspace(0,1e-5,1e4);
plot(y,f(y),y,h(y))