- Using the control
- Solving a shared equation
- Solving single equation
- Numeric TextBox
- How control works
- Control properties
- Control events
- Sample program
- Adding control to the project
Suppose that you have this Equation:
And your program has 7 textboxes for parameters z, u, h, p, j, v and y.Your program should be able to evaluate the value of each parameter according to the value of other textboxes and current formula.You may try to find a relationship for each parameter according to other parameters.For example for y (which is easier than other) we have:
y = 3* (23*h^4-Sin(z^2)-u*h-p^2-Atn(Cos(j*v))+23)
And then you define corresponding properties for the values of textboxes.
Using the control
1. Solving a Shared Equation
Let's say that using SNAT you even do not need to evaluate such formulae and no need to make lots of properties and methods. NO CODE NEEDED you only:
- name the parameter property of all SNATs
- Set the value of Formula
Now just focus on the textbox you want and press F5 to evaluate the value. This also can be done using Solve method of SNAT.There are some points that user should remember: (Read Carefully)
1.1. Some equations may have more than one root. In the case you have to set the Shared_MIN & Shared_MAX properties of corresponding SNAT.
The control will automatically find the root (if available). For example you want a root between 10 and 500.SNAT starts with initial value of 255 for MULLER method. If it couldn't find the root the domain will be divided in two sub-domains and both of them will be examined for the root. These divisions are called Steps which is a property in SNAT and is equal to 4 by default. A SNAT with 4 steps will work to the final amount of 16 divisions.
For example the absolute pressure can not be negative and if you have p^2 in the equation you may get a negative value for the root. Just change the Shared_MIN and Shared_MAX properties to the values that you accept logically.
2. All parameters are case sensitive except X. Remember that x (or X) is always an unknown. So you can not use it as a parameter. For example if you have 4 SNATs with parameters y1, y2, z and t. you type "X*y1+z^2-t*y2" in another SNAT and press Enter. This will calculate the value of x and leave it in the current SNAT.
3. These functions are valid in SNAT: Sin, Cos, Tan, Atn, Abs, Int, Fix, Log, Exp, Sqr, Sgn (All VBA math module functions) For more functions such as Ln, Ei, Integration, … wait for next version of SNAT.
4. Remove all the possible infinite values of the equation For example if you have ((y^3+z-1)/(j*(t-1))) -2.5 this will return infinity when t=1 or j=0 just write the formula in a linear form. Like this: (y^3+z-1) -2.5*(j*(t-1))
5. SNAT is the fastest .Net control for solving such equations that's why it applies Visual FORTRAN DLL for this purpose. If it freezes in some cases that's the result of your Steps property that tries to find a root between shared_min and shared_max. This will raise the Step_Iteration event. If the function is not sinuous shaped with high frequency you do not need high Steps to get the goal. Any way ill separate its thread in the next version for better performance.
2. Solving Single Equation
The parameter x (or X) is reserved for this purpose. You just type the equation in the SNAT, press enter and see the result.You can use other SNAT parameters in your equation! all of them know each other and their values.
Pressing enter results in direct evaluation of argument in the SNAT. You can use other SNAT parameters in this part too!
4. Numeric TextBox
If you set the calculator property of SNAT to false it will be an ordinary Numeric textbox which only accepts digits. It has also a dynamic decimal point. I mean if you go to the end of the digit and place a decimal point and go back to the starting point and place another decimal point, the first point will be removed. Also you can see all validated values of textbox using mouse wheel.
How Control Works
The greatest problem was that i coudnt send the address of a function in .Net to visual fortran.but it was possible using VB6.so Control has 3 main dlls:
- .Net DLL
- VB6 DLL
- Visual Fortran DLL
the .Net dll gets the text box values and replaces the parameters in the function by their value and produces the raw equation.it sends this string to vb6 dll.this vb6 dll sets the value of a public string which is being evaluated for different values of x using vbscript.this evaluation occures in a function and vb6 dll sends the handle to this functions to visualfortran dll to evaluate unknown(x). vf dll sends evaluated value to vb6 and vb6 to .net and .net to the current textbox!
It can be OnEnter,OnValidate and OnBoth.
Being true says that you want to use the calulational abilities of the control. if not it will be only a numerical textbox.
The shared formula between snats. it is needed in "solving a shared equation"
The initial value of "solving single equation" for MULLER method.
The corresponding parameter of a SNAT for example: y1.t.r.hy.ff
Number of steps that SNAT progresses to find a root in the prefered boundary of user. just used in "solving a shared equation"
Minimum value of unknown in "solving a shared equation"
Maximum value of unknown in "solving a shared equation"
It will be raised when equation is solved.
It will be raised when equation is not solved. it can be the result of no solution or bad form of equations that returns infinity and...etc
In "solving shared equation" shows that one step is passed
Solving a shared equation
its funny to make a sample program in zip file ready to download. thats why SNAT needs no code but i show you where you have to set the properties to get the solution.here is the property window of a SNAT which solves the equation ((y^3+z-1)) -2.5*(j*(t-1)) = 0
and these are SNATs. in the last SNAT (j), F5 is pressed and j is evaluated:
Solving sinlgle euqations
type the equation in term of x(or X) and other SNAT parameters:
and press Enter:
type the argument:(here y*t+z)
and press Enter:
Adding Control to Project
- Download the zip file and extract it where your application runs. For example in …bin\debug folder where the application executes.
- Add SNAT.dll to your .NET toolbox.